akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

char mp[1000][1000];
char e[2][2];

int dx[4] = {-1, 0, -1, 0}, dy[4] = {-1, -1, 0, 0};
char a[3] = {'J', 'O', 'I'};

int main()
{
	int h, w; scanf("%d %d", &h, &w);

	for (int i = 0; i < h; ++i) scanf("%s", mp[i]);

	for (int i = 0; i < 2; ++i) scanf("%s", e[i]);

	int sum = 0;

	for (int i = 0; i < h - 1; ++i) {
		for (int j = 0; j < w - 1; ++j) {
			if (mp[i][j] == e[0][0] && mp[i][j + 1] == e[0][1] && mp[i + 1][j] == e[1][0] && mp[i + 1][j + 1] == e[1][1]) {
				sum++;
			}
		}
	}

	int ans = sum;

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int sum2 = sum;

			char tmp = mp[i][j];

			int cnt = 0;

			for (int k = 0; k < 4; ++k) {
				int y = i + dy[k], x = j + dx[k];
				if (y < 0 || x < 0 || y + 1 >= h || x + 1 >= w) continue;
				if (mp[y][x] == e[0][0] && mp[y][x + 1] == e[0][1] && mp[y + 1][x] == e[1][0] && mp[y + 1][x + 1] == e[1][1]) {
					cnt++;
				}
			}

			sum2 -= cnt;
			
			for (int k = 0; k < 3; ++k) {
				mp[i][j] = a[k];

				int cnt2 = 0;

				for (int l = 0; l < 4; ++l) {
					int y = i + dy[l], x = j + dx[l];
					if (y < 0 || x < 0 || y + 1 >= h || x + 1 >= w) continue;
					if (mp[y][x] == e[0][0] && mp[y][x + 1] == e[0][1] && mp[y + 1][x] == e[1][0] && mp[y + 1][x + 1] == e[1][1]) {
						cnt2++;
					}
				}

				cnt = max(cnt, cnt2);
			}

			sum2 += cnt;

			mp[i][j] = tmp;

			ans = max(ans, sum2);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 2188
n = int(input())
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

#n = 4
#v_list = [13, 21, 6, 19]
#c_list = [11, 30, 6, 15]

v_minus_c = [v-c for (v, c) in zip(v_list, c_list)]
total = sum([s for s in v_minus_c if s>0])
print(total)


Measured memory_bytes: 38384
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	A := nextInt()
	P := nextInt()

	ans := (A*3 + P) / 2
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	ll ans=0;
	cin>>s;
	char c = s[0];
	FOR(i,0,s.size()){
		if(s[i]!=c)ans++;
		c=s[i];
	}
	cout << ans <<endl;
}

Measured memory_bytes: 512
n = int(input())
v = list(map(int, input().split()))
even_list = [0] * (100000 + 1)
odd_list = [0] * (100000 + 1)

for i in range(n):
    if i % 2 == 0:
        even_list[v[i]] += 1

    else:
        odd_list[v[i]] += 1

if even_list.index(max(even_list)) == odd_list.index(max(odd_list)):
    even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)
    print(min(n - even_sorted[-1] - odd_sorted[-2], n - even_sorted[-2] - odd_sorted[-1]))

else:
    print(n - max(even_list) - max(odd_list))


Measured memory_bytes: 14268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll d= 1000000000;
int main() {
int N,A,B,C,D;
cin >> N >> A >> B >> C >> D;
string S;
cin >> S;
bool flag1 = true;

bool flag5 = false;//初めのBの位置の前からDまでに.が３連続以上あるか


if(C>D){
    //#の連続数をカウント
    for(int i = A;i<C-1;i++){
        if(S[i]== '#' && S[i+1] == '#') {
            flag1 = false;
            break;
        }
    }
  for(int i = B-2;i<=D-2;i++){
    if(S[i]=='.' && S[i+1]=='.' && S[i+2]=='.'){
          flag5 = true;
          break;
      }
  }
  if(flag1 && flag5) cout <<"Yes" << endl;
  else cout << "No" <<endl;
}

if(C<D){
for(int i =A;i<D-1;i++){
        if(S[i]== '#' && S[i+1] == '#') {
            flag1 = false;
            break;
        }
    }
    if(flag1) cout << "Yes" <<endl;
    else cout << "No" <<endl; 
}


}

Measured memory_bytes: 640
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int n , k ;
	cin >> n >> k ; vi a(n) ;
	for(auto& x : a) cin >> x ;
	sort(all(a)) ;
	int sm = 0 ;
	for(int i = 0 ; i < (n-k) ; i++){
		sm += a[i] ;
	}
	cout << sm << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


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

int main () {
  string S;
  cin >> S;
  string ans="No";
  if (S[2]==S[3] && S[4]==S[5]) {
    ans="Yes";
  }

  cout << ans;
  return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cout << setprecision(10);
	cin >> n ;
	ll ans = 1 ;
	vector<int> a(n);
	rep(i,n) cin >> a[i];

	map<int,int> hat;

	for(int i = 0 ; i < n ; i ++){
		int now = a[i];
		hat[now] ++ ;
		if(hat[now] == 0){
			break ;
		}
		if(a[i] == 0){
			ans *= 3-hat[now]+1;
			ans %= mod;
		}
		else {
			ans *= hat[now - 1] - hat[now] + 1;
			ans %= mod;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

ll gcd(ll a, ll b){
  if(a < b){
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a%b) : a;
}

ll lcm(ll a, ll b){
  return a * b / gcd(a, b);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B; cin >> A >> B;

  cout << lcm(A, B) << endl;
}

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

int main() {
    int64_t a, b, n;
    cin >> a >> b >> n;
    if(n >= b) n = b - 1;
    int64_t ans = ((a * n) / b) - (a * (n / b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first昇順
	return forall_a_in_P.first < forall_b_in_P.first;
}
bool ps2(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first降順
	return forall_a_in_P.first > forall_b_in_P.first;
}
bool ps3(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second昇順
	return forall_a_in_P.second < forall_b_in_P.second;
}
bool ps4(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second降順
	return forall_a_in_P.second > forall_b_in_P.second;
}

int main()
{
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	ll cnt=0;
	rep(i,n){
		cnt+=a[i]/2;
		if(a[i]%2!=0&&a[i+1]>0){
			a[i+1]++;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    int n;
    cin >> n;
    int ans = 0;
    while(ans == 0){
        bool ok = true;
        rep(i,2,sqrt(n)){
            if(n%i == 0){
                ok = false;
                break;
            }
        }
        if(ok){
            ans = n;
        }
        n++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int n,a,b,c,counter;
 
  while(scanf("%d",&n)!=EOF){
    counter=0;
    for(a=0;a<=9;++a){
      for(b=0;b<=9;++b){
    for(c=0;c<=9;++c)
      if(0 <= n-a-b-c && n-a-b-c <= 9)
        counter++;
      }
    }
      printf("%d\n",counter);
  }
  return 0;
}

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

    using namespace std;

    const int INF = 1e9 + 1;

    int main()
    {
        int n, k;

        cin>>n>>k;

        vector<int> stones(n);

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

        vector<int> dp(n, INF);

        dp[0] = 0;

        for(int i = 0; i < n; i++)
        {
            for(int j = i + 1; j <= i + k; j++)
            {
                if(j < n)
                {
                    dp[j] = min(dp[j], dp[i] +  abs(stones[j] - stones[i]));
                }
            }
        }

        cout<<dp[n-1];

        return 0;
    }

Measured memory_bytes: 4044
si = require('fs').createReadStream('/dev/stdin');

rl = require('readline').createInterface({
  input: si, output: process.stdout});

dic = {};

rl.on('line', function (line) {
  var inst = line.split(' ');
  if (inst[0] === 'insert') dic[inst[1]] = null;
  else if (inst[0] === 'find')
    console.log(dic.hasOwnProperty(inst[1]) ? 'yes' : 'no');
});

Measured memory_bytes: 89844
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main() {
    IOS;

    ll n; cin>>n;
    map<string, ll> palabras;
    forn(i){
        string s; cin>>s;
        sort(all(s));
        palabras[s]++;
    }

    ll cont = 0;
    for(auto it: palabras) cont+= (it.second*(it.second-1))/2;
    cout<<cont<<endl;

    return 0;
}


Measured memory_bytes: 11264
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 3e3+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

double p[nmax];
double dp[nmax][nmax];

int main()
{
    optimizeIO();

    int n;
    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>p[i];

    dp[0][0] = 1;

    for(int c=1;c<=n;c++)
    {
        for(int h=0;h<=n;h++)
        {
            double p1 = 0 , p2 = 0;

            if(h>0) p1 = dp[h-1][c-1] * p[c];
            p2 = dp[h][c-1] * (1-p[c]);

            dp[h][c] = p1 + p2;
        }
    }

    double ans = 0;

    for(int h=0;h<=n;h++)
    {
        int t = n-h;

        if(h>t)
            ans += dp[h][n];
    }

    cout << setprecision(9) << ans<<endl;;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 74276
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(i>1&&i<a&&j<b&&j>1)printf(".");
	  else printf("#");
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}



Measured memory_bytes: 2040
# Generated by AtcoderGreedy on 2018-04-21
# ARC096 D
# Your code here

def input_stdin
  n, c = gets.chomp.split(' ').map(&:to_i)
  sushis = []
  n.times do
    sushis << gets.chomp.split(' ').map(&:to_i)
  end
  [n, c, sushis]
end

def input_example1
  require 'pry-byebug'
  require 'pry'
  [3, 20,
   [[2, 80],
    [9, 1],
    [16, 120]]]
end

def input_example0
  require 'pry-byebug'
  require 'pry'
  [3, 20,
   [[2, 80],
    [9, 120],
    [16, 1]]]
end

N, C, sushis = input_stdin

class Problem
  def initialize(sushis, counterpart = nil)
    @sushis = sushis
    @counterpart = counterpart
  end
  attr_reader :sushis

  def counterpart
    @counterpart ||=
      begin
        self.class.new(
          sushis.map { |x, v| [C - x, v] }.sort,
          self
        )
      end
  end

  def candidates
    @candidates ||=
      begin
        ans = [[0, 0]]
        sushis.each do |x, v|
          prev_x, prev_v = ans.last
          ans << [x, prev_v + v - (x - prev_x)]
        end
        ans.map { |x| x[1] }
      end
  end

  def maxes
    @maxes ||=
      begin
        ret = []
        ret << candidates.first
        candidates.drop(1).each do |cand|
          ret << [ret.last, cand].max
        end
        ret
      end
  end

  def find_best
    cands = candidates.drop(1).map.with_index do |cand, i|
      x, v = sushis[i]
      cand + counterpart.maxes[N - i - 1] - x
    end
    [cands.max, counterpart.maxes[N]].max
  end
end


pair_world = Problem.new(sushis)

binding.pry if binding.respond_to? :pry

normal_best = pair_world.find_best
counter_best = pair_world.counterpart.find_best

puts [normal_best, counter_best].max


Measured memory_bytes: 33112
use proconio::{input, fastout};
use std::cmp::{max};

struct UnionFind {
    parents: Vec<isize>,
}

impl UnionFind {
    fn new(n: usize) -> Self {
        UnionFind { parents: vec![-1; n] }
    }

    fn root(&mut self, x: &usize) -> usize {
        let px = self.parents[*x];
        if px < 0 {
            return *x;
        } else {
            let pp = self.root(&(px as usize));
            self.parents[*x] = pp as isize;
            return pp;
        }
    }

    fn same(&mut self, x: &usize, y: &usize) -> bool {
        self.root(x) == self.root(y)
    }

    fn join(&mut self, x: &usize, y: &usize) {
        let rx = self.root(x);
        let cx = self.parents[rx];
        let ry = self.root(y);
        if rx == ry { return; }
        self.parents[rx] = ry as isize;
        self.parents[ry] += cx;
    }

    fn size(&mut self, x: &usize) -> usize {
        let rx = self.root(x);
        -self.parents[rx] as usize
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize, usize); m],
    }

    let mut uf = UnionFind::new(n);
    for (mut a, mut b) in ab {
        a -= 1;
        b -= 1;
        uf.join(&a, &b);
    }
    let mut ans = 0;
    for i in 0..n {
        ans = max(uf.size(&i), ans);
    }
    println!("{}", ans)
}


Measured memory_bytes: 12216
#include<bits/stdc++.h>
using namespace std; 
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	double r;
	cin >> r;
	double ans = (2*r*22)/7;
	std::cout << std::setprecision(20);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int x, y, a, b, c;
    ll res = 0;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep (i, a) cin >> p[i];
    rep (i, b) cin >> q[i];
    rep (i, c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    priority_queue<ll> pq;
    rep (i, x) pq.push(p[i]);
    rep (i, y) pq.push(q[i]);
    rep (i, c) pq.push(r[i]);
    rep (i, x + y) {
        res += pq.top();
        pq.pop();
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 8688
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W,H,N;
    cin >> W>>H>>N;
    int left=0,right=W,bottom=0,top=H;
    REP(i,N){
        int a,b,c;
        cin >> a >> b >> c;
        if(c==1) chmax(left,a);
        else if(c==2) chmin(right,a);
        else if(c==3) chmax(bottom,b);
        else chmin(top,b);
    }
    if(left<right&&bottom<top) cout << (right-left)*(top-bottom) << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
/* ***********************************************
Author        :devil
************************************************ */
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stdlib.h>
#define inf 0x3f3f3f3f
#define LL long long
#define rep(a,b) for(int i=a;i<b;i++)
#define dec(a,b) for(int i=a;i>=b;i--)
#define ou(a) printf("%d\n",a)
#define pb push_back
#define mkp make_pair
template<class T>inline void rd(T &x){char c=getchar();x=0;while(!isdigit(c))c=getchar();while(isdigit(c)){x=x*10+c-'0';c=getchar();}}
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);
using namespace std;
const int mod=1e9+7;
const int N=1e5+10;
int main()
{
    //IN
    LL a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a>c) swap(a,c);
    if(b>c) swap(b,c);
    if(a%2==0||b%2==0||c%2==0) printf("0\n");
    else printf("%lld\n",a*b);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i=0,t=0;
	char s[101];


	scanf("%s",s);
     
	while(s[i]!='\0'){
		if((i%2==0)&&(s[i]!='L'))	
			t++;
		else if((i%2==1)&&(s[i]!='R'))
			t++;

		i++;
	}
		if(i==t)
			printf("Yes\n");
		else
			printf("No\n");

		return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int i,x;
	i=1;
	
	for(i;;i++){
		cin >> x;
		if(x!=0){
			cout << "Case" << " " << i << ":" << " " << x << endl;
		}
		else break;
	}
return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
int abs(int x){
if(x<0)
    return x*-1;
else
    return x;
}
int main(){
int n;
cin>>n;
int i,j;
pair<int,int> a[n+1];
for(i=1;i<=n;i++){
    int g;
    cin>>g;
    a[i]=mp(g,i);

}
sort(a+1,a+n+1);
set<int> a0;
set<int> a1;
set<int> b0;
set<int> b1;
int c[n+1];
for(i=n;i>=1;i--){

   int x=abs(i-a[i].second);

   c[a[i].second]=x%2;
if(a[i].second%2){

    if(x%2)
        a1.insert(a[i].second);
    else
        a0.insert(a[i].second);

}
else{



    if(x%2)
        b1.insert(a[i].second);
    else
        b0.insert(a[i].second);





}}

int ans=0;
set<int>::iterator s;
for(i=n;i>=1;i--){

     if(c[a[i].second]==0)
        {
            if(a[i].second%2)
                a0.erase(a[i].second);
            else
            b0.erase(a[i].second);
            continue;}
     ans++;

     if(a[i].second%2){

        a1.erase(a[i].second);
        if(b1.empty()){
            s=b0.begin();
            c[*s]=1;
            b0.erase(*s);
            b1.insert(*s);

        }
        else{
           s=b1.begin();
           c[*s]=0;
           b1.erase(*s);
           b0.insert(*s);


        }

     }
     else{

        b1.erase(a[i].second);
        if(a1.empty()){
            s=a0.begin();
            c[*s]=1;
            a0.erase(*s);
            a1.insert(*s);

        }
        else{
           s=a1.begin();
           c[*s]=0;
           a1.erase(*s);
           a0.insert(*s);


        }

     }







}
cout<<ans<<endl;



return 0;
}




Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N; cin >> N;
	int l[1001], r[1001];
	int count = 0;
	rep(i, 0, N) {
		cin >> l[i] >> r[i];
		count += r[i] - l[i] + 1;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const lli INF = 1e18L + 5;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

        lli n ,W;
    cin >> n >> W;
    vector<lli> w(n+1,0) ,v(n+1,0);
    for(int i = 1 ; i <= n ; ++i)cin >> w[i] >> v[i];
 
    lli m = 0;
    for(auto it : v) m += it;
    vector<lli> dp(m+1,INF);
   dp[0] = 0;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = m ; j >= v[i] ; --j){
            if(j >= v[i])
            dp[j] = min(dp[j],dp[j-v[i]] + w[i]);
        }
    }
    lli ans = 0 ;
    
    for(int i = 1 ; i <=m; ++i){
        // cout << dp[i] << endl;
        if(dp[i] <= W) ans = i;
        }
        // if(dp[i] <= W)
        //     ans = max(ans, (lli)i);

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

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

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

  string n;
  cin >> n;

  char c = n.back();
  if(c == '2' or c == '4' or c == '5' or c == '7' or c == '9') {
    cout << "hon" << '\n';
  } else if(c == '3') {
    cout << "bon" << '\n';
  } else {
    cout << "pon" << '\n';
  }
}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var O, E string
	var p []byte
	fmt.Scan(&O, &E)
	for i := 0; i < len(O) && i < len(E); i++ {
		p = append(p, O[i])
		p = append(p, E[i])
	}
	if len(O) != len(E) {
		if len(O) > len(E) {
			p = append(p, O[len(O)-1])
		} else {
			p = append(p, E[len(E)-1])
		}
	}
	fmt.Println(string(p))
}


Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vi l(q), r(q);
  rep(i, q) cin >> l[i] >> r[i];

  vi cv(n); int cnt=0;
  for(int i=1;i<n;i++){
    if (s[i-1] == 'A' and s[i] == 'C'){
      cnt++;
    }
    cv[i] = cnt;
  }

  rep(i, q){
    int ans = cv[r[i] - 1] - cv[l[i] - 1];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int n,t,a[100005],mx[100005],cnt=0,kmp=0;
int main()
{
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		//mx[i]=max(mx[i-1],a[i]);
	}
	mx[n]=a[n];
	for(int i=n-1;i>=1;i--)
	{
		mx[i]=max(mx[i+1],a[i]);
	}
	for(int i=1;i<n;i++)
	{
		if(mx[i+1]-a[i]>kmp)
		{
			kmp=mx[i+1]-a[i];
			cnt=1;
		}else if(mx[i+1]-a[i]==kmp)
		{
			++cnt;
		}
	}
	printf("%d\n",min(cnt,kmp/2));
}

Measured memory_bytes: 4512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX=3000;

signed main(){
    int a,b;cin>>a>>b;
    cout<<(a+b)%24<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld a,c,r,j,l,x,y,m,b,n,s,f,q,i,z,p,k,d,t,u,e,g;string s1,s2,s3,s4;
vi v[10000001];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>s1>>s2>>s3;
  cout<<s1[0]<<s2[1]<<s3[2];
}

Measured memory_bytes: 234624
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    LL n, k;
    cin >> n >> k;
    vector<LL> a(n);
    REP(i, n) cin >> a[i];

    vector<LL> b(45), c(45);
    REP(i, 45){
        REP(j, n) b[i] += (a[j] & (1LL << i)) xor (1LL << i);
        REP(j, n) c[i] += (a[j] & (1LL << i)) xor 0LL;
    }

    vector<vector<LL>> dp(50, vector<LL>(2, -1));
    dp[45][0] = 0;

    for (int i = 44; i >= 0; i--) {
        LL mask = (1LL << i);
        if(dp[i+1][1] >= 0){
            dp[i][1] = max(dp[i][1], dp[i+1][1] + max(b[i], c[i]));
        }
        if(dp[i+1][0] >= 0){
            if(k & mask){
                dp[i][0] = max(dp[i][0], dp[i+1][0] + b[i]);
                dp[i][1] = max(dp[i][1], dp[i+1][0] + c[i]);
            }else{
                dp[i][0] = max(dp[i][0], dp[i+1][0] + c[i]);
            }
        }
    }

    cout << max(dp[0][0], dp[0][1]) << endl;
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

ll divisor(ll n) {
    ll res = pow(n, 0.5);
    while(n % res != 0) {
        res--;
    }
    return res;
}

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

    ll n; cin >> n;
    ll div = divisor(n);
    ll ans = (div - 1) + (n / div - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <random>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1ll<<50 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
	ll n,m,r ;
	cin >> n >> m >> r ;
	vll t(r) ;
	for(auto &i:t) cin >> i ;
	for(int i=0;i<r;i++) t[i]-- ;
	vvll d(n,vll(n,INF)) ;
	for(int i=0;i<n;i++) d[i][i] = 0 ;
	for(int i=0;i<m;i++){
		ll a,b,c ;
		cin >> a >> b >> c ;
		a-- ; b-- ;
		d[a][b] = d[b][a] = c ;
	}
	for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) chmin(d[i][j],d[i][k]+d[k][j]) ;
	sort(all(t)) ;
	ll ans = INF ;
	do{
		ll sub = 0 ;
		for(int i=1;i<r;i++) sub += d[t[i-1]][t[i]] ;
		chmin(ans,sub) ;
	}while(next_permutation(all(t))) ;
	cout << ans << endl ;
}


Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<ctime>
#include<vector>
#include<stack>
#include<map>
using namespace std;

int digit(int n){
  int ret = 0;
  while(n){
    ret += n%10;
    n /= 10;
  }
  return ret;
}

int main(){
  int n; cin >> n;
  int mn = 1e9;
  for(int i = 1 ; i+i <= n ; i++){
    mn = min(mn, digit(i)+digit(n-i));
  }
  cout << mn;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	cin >> n;
	string S;
	rep(i,n){
		int OUT = 0;
		int mnd = 0;
		int score = 0;
		while(OUT != 3){
			cin >> S;
			if(S == "OUT")OUT++;
			if(S == "HIT"){
				mnd++;
				if(mnd > 3){
					mnd--;
					score++;
				}
			}
			if(S == "HOMERUN"){
				score += mnd+1;
				mnd = 0;
			}
		}
		FIN(score);

	}

	return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
int main(void){
char s[10];
  scanf("%s",&s);
  if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){printf("Yes");return 0;}
    if(s[0]==s[1]&&s[1]==s[2]){printf("Yes");return 0;}
    if(s[1]==s[2]&&s[2]==s[3]){printf("Yes");return 0;}
  printf("No");
              
return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    for(int i=x;i<10000000;i++){
      if(isPrime(i)){
        System.out.println(i);
        return;
      }
    }
    

  }
  
  public static boolean isPrime(int x){
    boolean result = true;
    for(int i =2;i<(int)Math.floor(Math.sqrt(x));i++){
      if(x%i==0){
        return false;
      }
    }
    return result;
  }
  

  
}


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

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

const int INF = 1 << 30;
int T, N;
int t[30], D[110], M[110];
int getup[110];
int dp[110][30];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> T, T) {
    fill(getup, getup + 110, 24);
    for (int i = 0; i < T; i++) {
      cin >> t[i];
    }
    cin >> N;
    for (int i = 0; i < N; i++) {
      cin >> D[i] >> M[i];
      getup[D[i]] = min(getup[D[i]], M[i]);
    }

    int D_max = *max_element(D, D + N);
    fill((int *)dp[0], (int *)(dp[0] + 30), INF);
    dp[0][T - 1] = 0;
    for (int i = 0; i < D_max; i++) {
      for (int j = 0; j < T; j++) {
        dp[i + 1][j] = INF;
        if (t[j] > getup[i + 1]) continue;
        if (j == 0) {
          for (int k = 0; k < T; k++) {
            if (dp[i][k] == INF) continue;
            if (k == (j + T - 1) % T) dp[i + 1][j] = min(dp[i + 1][j], dp[i][k]);
            else dp[i + 1][j] = min(dp[i + 1][j], dp[i][k] + 1);
          }
        } else {
          dp[i + 1][j] = dp[i][(j + T - 1) % T];
        }
      }
    }

    int ans = INF;
    for (int i = 0; i < T; i++) {
      ans = min(ans, dp[D_max][i]);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

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

    vl mae(n);  // a[i]より前にあるa[i]より小さい数の個数
    vl ushiro(n);  // a[i]より後ろにあるa[i]より小さい数の個数
    rep(i, n) {
        exrep(j, 0, i-1) {
            if(a[j] < a[i]) {
                mae[i]++;
            }
        }
    }
    rep(i, n) {
        exrep(j, i+1, n-1) {
            if(a[j] < a[i]) {
                ushiro[i]++;
            }
        }
    }
    
    ll ans = 0;
    rep(i, n) {
        ll x = (k*(k+1)/2)%mod;
        ans += (ushiro[i]*x)%mod;
        ans %= mod;
    }
    rep(i, n) {
        ll x = (k*(k-1)/2)%mod;
        ans += (mae[i]*x)%mod;
        ans %= mod;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll check[110000]={};
  ll n, x, m;
  cin >> n >> x >> m;
  if(x==0) {
    cout << 0 << endl;
    return 0;
  }
  vll v;
  ll cnt = 0LL;
  ll a = x;
  rep(i,m+10) {
    v.push_back(a);
    cnt += a;
    check[a] = true;
    a *= a;
    a %= m;
    if(check[a]) break;
    if(a==0) {
      cout << cnt << endl;
      return 0;
    }
  }
  if(a==x) {
    ll s = v.size();
    ll ans = 0LL;
    ll c = n - n%s;
    ll b = c/s;
    ans += cnt*b;
    rep(i,n%s) ans += v[i];
    cout << ans << endl;
  }
  else {
    ll ans = 0LL;
    bool swi = true;
    vll vv;
    ll vs = v.size();
    rep(i,vs) {
      if(v[i]==a) swi = false;
      if(swi) {
        ans += v[i];
        n--;
      }
      else vv.push_back(v[i]);
    }
    ll s = vv.size();
    ll sum = 0LL;
    rep(i,s) sum += vv[i];
    ll b = n/s;
    ans += sum*b;
    rep(i,n%s) ans += vv[i];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 5084
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

int main() {

    int N;
    cin >> N;
    vector<int>A(N + 1);
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        A[a] = i;
    }

    for (int i = 1; i <= N; i++){
        cout << A[i] << " ";
    }
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void){
  int n, s[100], i, sum=0, min=100;
  scanf("%d", &n);
  for(i=0; i<n; ++i){
    scanf("%d", &s[i]);
    sum += s[i];
    if(s[i]%10 != 0 && min > s[i])
      min = s[i];
  }
  if (sum%10 == 0) {
    sum -= min;
  }
  if (min == 100){
    printf("%d\n", 0);
  }else{
    printf("%d\n", sum);
  }
  return 0 ;
}
     

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, m, t, a[109];
int main() {
	cin >> n >> m >> t; a[0] = -m, a[n + 1] = t + m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ret = 0;
	for (int i = 0; i <= n; i++) ret += max(a[i + 1] - a[i] - 2 * m, 0);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n;
P a[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i].first;
	rep(i, n)a[i].second = i + 1;
	sort(a, a + n);
	cout << a[0].second << endl;
	ggr
}




Measured memory_bytes: 4668
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	int cnt0 = 0;
	map<int, int> mp;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		if (a[i] == 0) { ++cnt0; }
		mp[a[i]] += 1;
	}

	bool ok = false;
	if (cnt0 == N) { ok = true; }
	if (N % 3 == 0 && mp.size() <= 3) {
		vector<int> v;
		bool f = true;
		for (auto it = mp.begin(); it != mp.end(); ++it) {
			int x = it->second;
			int y = N / 3;
			if (x % y != 0) { f = false; }
			for (int i = 0; i < x / y; ++i) { v.push_back(it->first); }
		}
		if (v.size() != 3) { f = false; }
		if (f && (v[0] == (v[1]^v[2])) && (v[1] == (v[0]^v[2])) && (v[2] == (v[1]^v[0]))) {
			ok = true;
		}
	}
	cout << (ok ? "Yes" : "No") << endl; 

	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline void LB(vector<T>& v, T& a) { return *lower_bound(ALL(v),a); }
template <typename T> inline void LBP(vector<T>& v, T& a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline void UB(vector<T>& v, T& a) { return *upper_bound(ALL(v),a); }
template <typename T> inline void UBP(vector<T>& v, T& a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template< typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; }
template< typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;
int x[100010],y[100010];
vector<int> g[200010];
bool vis[200010];

void dfs(int v, int f, int& w, int& b) {
  (f == 0 ? w : b) += 1;
  vis[v] = true;
  for (int nv : g[v]) if (!vis[nv]) {
    dfs(nv,f^1,w,b);
  }
}

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

  cin >> N;
  REP(i,N) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
    g[x[i]].push_back(y[i]+100000);
    g[y[i]+100000].push_back(x[i]);
  }
  int ans = 0;
  REP(i,200010) if (!vis[i]) {
    int w = 0, b = 0;
    dfs(i,0,w,b);
    ans += w*b;
  }
  ans -= N;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
 
using namespace std;
 
using ll = long long;
 
int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i=a; i<=b; ++i) {
        if (i%k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl; 
}

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

#define N 100
#define MAX 100001
#define che cout<<"-----"<<endl

int cnt = 0;

class Po{
public:
    int i;
    int d;
    int o;
};

void change(Po *a, int i);
void maxHeapify(Po *a, int i);
void buildMaxHeap(Po *a, int n);

int main() {
    
    Po a[N][N];
    int n, u, k, c, v;
    cin>>n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            a[i][j].d = MAX;
        }
    }
    
    for(int i = 0; i < n; i++) {
        cin>>u>>k;
        for(int j = 0; j < k; j++) {
            cin>>c>>v;
            a[u][c].d = v;
            a[u][c].i = c;
            a[u][c].o = u;
        }
    }
    
    int list[N];
//    for(int i = 0; i < n; i++) list[i] = MAX;
    list[0] = 0;
    Po q[100000], mini;
    for(int i = 1; i < n; i++) {
        if(a[0][i].d != MAX) {
            cnt++;
            q[cnt] = a[0][i];
            change(q, cnt);
        }
    }
    
    int num = 0;
    while(1) {
        mini = q[1];
        q[1] = q[cnt];
        cnt--;
        maxHeapify(q, 1);
        if(list[ mini.i ] == 0) {
            list[ mini.i ] = mini.d;
            for(int i = 1; i < n; i++) {
                if(a[mini.i][i].d != MAX) {
                    cnt++;
                    a[mini.i][i].d += mini.d;
                    q[cnt] = a[mini.i][i];
                    change(q, cnt);
                }
            }
            num++;
        }
        if(num == n-1) break;
    }
    
    for(int i = 0; i < n; i++) {
        cout<<i<<' '<<list[i]<<endl;
    }
    
    return 0;
}

void change(Po *a, int i) {
    int p = i % 2 == 0 ? i/2 : (i-1)/2;
    if(p >= 1 && a[i].d < a[p].d ) {
        Po tmp = a[i];
        a[i] = a[p];
        a[p] = tmp;
        change(a, p);
    }
}

void maxHeapify(Po *a, int i) {

  int l = i*2;
  int r = i*2+1;

  int largest = i;
  if(l <= cnt && a[l].d < a[largest].d )  largest = l;

  if(r <= cnt && a[r].d < a[largest].d ) largest = r;

  if(largest != i) {
    Po s = a[i];
    a[i] = a[largest];
    a[largest] = s;
    maxHeapify(a, largest);
  }
}



Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{

    class Program
    {
        static void Main(string[] args)
        {
            int size = 'z' - 'a' + 1;
            int[] cnt = new int[size];
            string str;
            while (null != (str = Console.ReadLine()))
            {
                str = str.ToLower();
                for(var i = 0; i < str.Length; i++)
                {
                    if (char.IsLetter(str[i]))
                    {
                        cnt[str[i] - 'a']++;
                    }
                }
            }
            for(var i = 0; i < size; i++)
            {
                Console.WriteLine("{0} : {1}",Convert.ToChar('a'+i),cnt[i]);
            }

        }
    }
}

Measured memory_bytes: 9316