akhauriyash/Code-Regression huggingface dataset:
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    
    //行き
    int pos=n-1;
    bool ok=false;
    for(int i=n-1;i>=0;i--){
        if((pos-i)*10<=v[i]){
            pos=i;
            if(i==0)ok=true;
        }
    }

    if(!ok){
        cout<<"no"<<endl;
        return 0;
    }

    //帰り
    pos=0;
    ok=false;
    rep(i,0,n){
        if((i-pos)*10<=v[i]){
            pos=i;
            if(i==n-1)ok=true;
        }
    }

    if(!ok){
        cout<<"no"<<endl;
        return 0;
    }
    cout<<"yes"<<endl;

    
    

}



    


Measured memory_bytes: 3896
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll l,r,d;
	 cin>>l>>r>>d;

	 ll ans= (r+d)/d - (l+d-1)/d;

	 cout<<ans<<"\n";

	
	return 0;
}

Measured memory_bytes: 3604
#include<cstdio>

int main(){
  int m,f,r,p;
  while(1){
    scanf("%d %d %d",&m,&f,&r);
    if(m == -1 && f == -1 && r == -1) break;
    p = m + f;
    if(m == -1 || f == -1){
      printf("F\n");
    }else if(p >= 80){
      printf("A\n");
    }else if(65 <= p && p < 80){
      printf("B\n");
    }else if(50 <= p && p < 65 || r >= 50){
	printf("C\n");
    }else if(30 <= p && p < 50){
      printf("D\n");
    }else if(p < 30){
      printf("F\n");
     }
    }
    return 0;
  }

Measured memory_bytes: 1012
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (n, t) = get!(usize, usize);
    let ct = get!(usize, usize; n);

    let mut ctm = ct.into_iter()
       .filter(|&(_, tt)| tt <= t)
       .collect::<Vec<_>>();
    ctm.sort();

    if ctm.len() == 0 {
        println!("TLE");
    } else {
        println!("{}", ctm[0].0);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include<vector>
#include<stdio.h>

#define FOR(i,n) for(int i=0;i<n;i++)
#define SORT(v,n) sort(v[0],v[n-1])
#define INF 999999999
#define mod 1000000007

using namespace std;

int main(){

	long long x;
	cin >> x;
	long long ans;

	long long q=x/11;
	long r=x%11;

	/*if(x==11){
		cout << 2 << endl;
		return 0;
	}*/

	if(r>6){
		ans=q*2 +2;
	}else if(r!=0){
		ans=q*2+1;
	}else{
		ans=q*2;
	}

	cout << ans << endl;

}


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

const int COINVALUE[3] = {50, 10, 5} ;

int ans = 0;
int coin[3];
int tar;

int ArchMage(int, int);

int main()
{
    cin >> coin[0] >> coin[1] >> coin[2] >> tar ;

    tar /= 10;

    ArchMage(0, 0);

    cout << ans << endl;
}

int ArchMage(int chosen, int val)
{
    if(chosen == 3)
    {
        if (val == tar)
            ans++;
        return 0;
    }

    if(val > tar)
        return 1;

    for(int i = 0; i <= coin[chosen]; i++)
        ArchMage(chosen+1, \
                  val + COINVALUE[chosen]*i);

    return 2;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int cal_100(int n){
    int sum = 0;
    while(n % 100 == 0 && n > 0){
        n /= 100;
        sum ++;
    }

    return sum;
}

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

    if(n == 100) ++ n;

    cout << n;
    rep(i, d * 2) cout << 0;
    cout << endl;
}

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

int n, q;
string s;
char t[200000], d[200000];

bool exit_from(int nn, char direction)
{
    int a = nn;

    for (int i = 0; i < q; i++) {
        if (t[i] != s[a]) {
            continue;
        }

        if (d[i] == 'L') {
            a--;
        } else {
            a++;
        }

        if (a < 0 && direction == 'L') {
            return true;
        }
        if (a > n - 1 && direction == 'R') {
            return true;
        }
    }

    return false;
}

int main() {
    cin >> n >> q >> s;
    for (int i = 0; i < q; i++) {
        cin >> t[i] >> d[i];
    }

    // 左から退場する一番右のマス
    int a = 0;
    int b = n - 1;

    int left = -1;

    while (1) {
        int search = a + ((b - a) / 2);
        if (exit_from(search, 'L')) {
            left = search;
            a = search + 1;
        } else {
            b = search - 1;
        }

        if (b < a) {
            break;
        }

    }

    // 右から退場する一番左のマス
    a = 0;
    b = n - 1;

    int right = n;

    while (1) {
        int search = a + ((b - a) / 2);
        if (exit_from(search, 'R')) {
            right = search;
            b = search - 1;
        } else {
            a = search + 1;
        }

        if (b < a) {
            break;
        }
    }

    cout << n - (left + 1) - (n - right) << endl;

    return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <map>
#include <cassert>
using namespace std;
typedef long long ll;
int N;
ll S[100010];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> S[i];
    ll ans = 0;
    for(int C=1;C<=N-1;C++){
        //if((N-1)%C!=0) continue;
        ll now = 0;
        for(int k=0;k*C<=N-1;k++){
            int A = N-1-k*C,B = A-C;
            now = now+S[N-1-k*C]+S[k*C];
            if(A<=B || B<=0) continue;
            if(A%C==0 && A/C<=k) continue;
            ans = max(ans,now);
//            cerr << "A:" << A << " B:" << B << " k:" << k << " C:" << C << " now:" << now << endl;
        }
        /*int C2 = (N-1)/C;
        now = 0;
        for(int k=0;k*C2<=N-1;k++){
            int A = N-1-k*C2,B = A-C2;
            now = now+S[N-1-k*C2]+S[k*C2];
            if(A<=B || B<=0) continue;
            if(A%C2==0 && A/C2<=k) continue;
            ans = max(ans,now);
        }*/
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

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) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

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

        if(n==1) return 1;

        long l = 2;
        long ll = 1;

        for(int i=2; i<=n; i++) {
            long lll = ll + l;
            l = ll;
            ll = lll;
        }

        return ll;
    }

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

}


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

using namespace std;

#define N 100000

vector<pair<int, long long> > g[N + 1];
long long d[N + 1];
bool seen[N + 1];

void dfs(int u, long long dist){
	long long w;
	int v, i;

	d[u] = dist;
	seen[u] = true;

	for (i = 0; i < (int)g[u].size(); i++){
		v = g[u][i].first;
		w = g[u][i].second;

		if (!seen[v]){
			dfs(v, dist + w);
		}
	}
}

int main(){
	int n, k, q, a, b, i;
	long long c;

	scanf("%d", &n);

	for (i = 1; i < n; i++){
		scanf("%d%d%lld", &a, &b, &c);

		g[a].push_back(make_pair(b, c));
		g[b].push_back(make_pair(a, c));
	}

	scanf("%d%d", &q, &k);

	dfs(k, 0);

	while (q--){
		scanf("%d%d", &a, &b);

		printf("%lld\n", d[a] + d[b]);
	}

	return 0;
}

Measured memory_bytes: 14336
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    q = int(line)
    if q == -1:
        break

    x = q / 2.0
    diff = q * 0.00001
    while True:
        x = x - (x**3 - q) / (3 * x * x)
        if abs(x**3 - q) < diff:
            break
    print('{:.6f}'.format(x))

Measured memory_bytes: 4352
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = input.split("\n");
  const a = parseInt(input.shift());
  if (a < 3200) {
    console.log("red");
  } else {
    console.log(input[0]);
  }
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	set<int> a;
	int b;
	
	cin >> b;
	a.insert(b);
	cin >> b;
	a.insert(b);
	cin >> b;
	a.insert(b);
	
	cout << a.size();
	
	return 0;
}

Measured memory_bytes: 256
#include<atcoder/all>
using namespace atcoder;

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<pair<int, int>, int>> p(n);
    rep(i, n){
        cin >> p[i].first.first >> p[i].first.second;
        p[i].second = i;
    }
    sort(all(p));
    dsu uf(n);
    set<P> st;
    rep(i, n){
        int mn = p[i].first.second;
        for(auto it = st.begin(); it != st.end(); it++){
            if(it -> first >= p[i].first.second)break;
            uf.merge(p[i].second, it -> second);
            chmin(mn, it -> first);
            st.erase(it);
        }
        st.insert({mn, p[i].second});
    }
    rep(i, n)cout << uf.size(i) << endl;
}


Measured memory_bytes: 11140
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    if (abs(a - b) <= t * (v - w)) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3132
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int maxn=100;
char a[maxn][maxn],b[maxn][maxn];

int main()
{
	int n,m;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		for(int i=0;i<n;i++)
		    scanf("%s",&a[i]);
		for(int i=0;i<m;i++)
		    scanf("%s",&b[i]);
		int flag=1;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
 
                if(a[i][j]==b[0][0])
                {
                    flag=0;
                    for(int x=0;x<m;x++)
                    {
                        for(int y=0;y<m;y++)
                        {
                            if(a[i+x][j+y]!=b[x][y])
                            {
                                flag=1;
                                break;
                            }
                        }
                    }
                } 
                if(flag==0)
                    break;  
            }
            if(flag==0)
                break;
        }
        if(flag==0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<long long> inp;
struct cmp
{
	bool operator()(const long long & a,const long long & b)const{
		return ((inp[a]-inp[a-1])<(inp[b]-inp[b-1]));
	}
};
multiset<long long,cmp> st;
long long solve()
{
	long long n,m,ans=0;cin>>n>>m;
	inp.resize(m);
	REP(i,0,m-1)
	{
		cin>>inp[i];
	}
	sort(inp.begin(),inp.end());
	if(n>=m){cout<<0<<"\n";return 0;}
	for(long long i=1;i<m;++i)
	{
		st.insert(i);
	}
	int ct=0;
	for(auto it:st)
	{
		++ct;
		ans+=(inp[it]-inp[it-1]);
		if(ct==(m-n)){break;}
	}
	cout<<ans<<"\n";
}
signed main(){
	speed
	long long tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		char c = sc.nextLine().trim().charAt(0);

		switch (c) {
		case 'A':
			System.out.println("T");
			break;
		case 'T':
			System.out.println("A");
			break;
		case 'C':
			System.out.println("G");
			break;
		case 'G':
			System.out.println("C");
			break;
		}
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    System.out.println(Math.min(a, b) + Math.min(c, d));

  }
}

Measured memory_bytes: 35508
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#define NUM 100

using namespace std;

int main(void){
    int N, M;
    int L_max, R_min;

    scanf("%d %d", &N, &M);
    for(int i = 0; i < M; i++){
        int L, R;
        scanf("%d %d", &L, &R);
        if(i == 0){
            L_max = L;
            R_min = R;
        }else{
            L_max = max(L, L_max);
            R_min = min(R, R_min);
        }
    }

    printf("%d\n", max(0, R_min - L_max + 1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
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);
}
int main()
{
    ll N, K, ans = 0;
    cin >> N >> K;
    ans = K;
    rep(i, N - 1)
        ans *= (K - 1);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <unordered_map>
using namespace std;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

bool compare_by_b(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<2>(a) != get<2>(b)){
        return get<2>(a) > get<2>(b);
    }
}

bool compare_by_string(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
      	return get<2>(a) > get<2>(b);
    }
}

int check(vector<int> &v, int k, long weight)
{
  int i=0;
  for(int j=0;j<k;j++)
  {
    long tmp = 0;
    while(tmp + v[i] <= weight)
    {
      tmp += v[i];
      i++;
      if(i == v.size()) return v.size();
    }
  }
  return i;
}


long binary_search(vector<int> &v, int k)
{
	long left = 0;
  	long right = v.size() * 10000; //適宜書き換え
  	long mid;
  	while(right - left > 1)
    {
      	mid = (left + right) / 2;
      	int num = check(v,k,mid);
      	if(num >= v.size()) right = mid;
      	else left = mid;
    }
  	return right;
}

bool isComb(vector<int> &elem, int idx, int sum)
{
  if(sum == 0) return true;
  else if(idx >= elem.size() || sum < 0) return false;
  return isComb(elem, idx+1, sum) || isComb(elem, idx+1, sum - elem[idx]);
}

struct Point
{
  double x;
  double y;
};

double PI = 3.14159265358979323846;

int coch_curve(Point s, Point e, int n)
{
  if (n == 0) return 0;
  Point next_s, next_e, mid;
  double th = PI * 60 /180;
  next_s.x = (s.x * 2 + e.x) / 3;
  next_s.y = (s.y * 2 + e.y) / 3;
  next_e.x = (s.x + e.x * 2) / 3;
  next_e.y = (s.y + e.y * 2) / 3;
  mid.x = (next_e.x - next_s.x) * cos(th) - (next_e.y -next_s.y) * sin(th) + next_s.x;
  mid.y = (next_e.x - next_s.x) * sin(th) + (next_e.y -next_s.y) * cos(th) + next_s.y;

  coch_curve(s, next_s, n-1);
  cout << fixed << setprecision(10) << next_s.x << " " << next_s.y << endl;
  coch_curve(next_s, mid, n-1);
  cout << fixed << setprecision(10) << mid.x << " " << mid.y << endl;
  coch_curve(mid, next_e, n-1);
  cout << fixed << setprecision(10) << next_e.x << " " << next_e.y << endl;
  coch_curve(next_e, e, n-1);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  	const long div = 1000000007;
	int n;
  	cin >> n;
  	Point s,e;
  	s.x = 0;
  	s.y = 0;
  	e.x = 100;
  	e.y = 0;
  	cout << fixed << setprecision(10) << s.x << " " << s.y << endl;
  	coch_curve(s, e, n);
  	cout << fixed << setprecision(10) << e.x << " " << e.y << endl;
  	return 0;
}



Measured memory_bytes: 3396
code=int(input())
arr = list(map(int, input().split()))
sumone=0
for i in range(code):
    for j in range(i+1,code):
        if arr[i]<arr[j]:
            box=arr[j]
            arr[j]=arr[i]
            arr[i]=box
for i in range(code):
    if i%2==0:
        sumone+=arr[i]
    else:
        sumone-=arr[i]
print(sumone)


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

int n, m, x;
int a[200];
int j = 0;
int main()
{
    cin >> n >> m >> x;
    for(int i = 0; i < m; i++)
    {
        cin >> a[i+1];
        if(j == 0 && a[i+1] > x)
        {
            j = i+1;
        }
    }
    
    cout << min(j-1, m-j+1) << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
int main()
{
	int a;
	int b;
	while(std::cin >> a >> b)
	{
		int number = 1;
		int data = a + b;
		for(int i = 0;;i++)
		{
			if(data / 10 != 0)
			{
				number += 1;
				data /= 10;
			}

			else if(data / 10 == 0)
			{
				break;
			}
		}
		std::cout << number << '\n';
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> w(n);
	rep(i, n)cin >> w[i];

	int s1 = w[0];
	int s2 = 0;
	for (int i = 1; i < n; i++) s2 += w[i];
	int ans = abs(s1 - s2);

	for (int t = 1; t < n - 1; t++) {
		s1 += w[t];
		s2 -= w[t];
		int diff = abs(s1 - s2);
		ans = min(ans, diff);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    string a;
    long int b[5]={0};
    cin>>N;
    while(N--)
    {
        cin>>a;
        if(a[0]=='M')
            b[0]++;
        else if(a[0]=='A')
            b[1]++;
        else if(a[0]=='R')
            b[2]++;
        else if(a[0]=='C')
            b[3]++;
        else if(a[0]=='H')
            b[4]++;
    }
    int flag=0;
    long long int s;
    for(int i=0; i<5; i++)
        if(b[i])
            flag++;
    if(flag<3)
        printf("0\n");
    else if(flag==3)
    {
        s=1;
        for(int i=0; i<5; i++)
            if(b[i])
                s*=b[i];
        cout<<s<<endl;
    }
    else if(flag>=4)
    {
        s=0;
        int x,y,z;
        for(x=0; x<3; x++)
            for(y=x+1; y<4; y++)
                for(z=y+1; z<5; z++)
                    if(b[x]&&b[y]&&b[z])
                        s+=b[x]*b[y]*b[z];
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
cnt, count = 0,0
ary = ['A','T','C','G']
for i in range(len(s)):
    for x in range(len(ary)):
        if ary[x] in s[i]:
            count+=1
            cnt = max(cnt,count)
            break
    else:count = 0
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
   int N;
   cin>>N;
   string S;
   cin>>S;
   REP(i,S.length()){
       int t = S[i] - 'A';
       t = (t + N)%26;
       S[i] = (char)('A' + t);
   }
   cout<<S<<endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  string s;
  cin >> s;
  if(s.back()=='s'){
    cout << (s+"es") << endl; 
  }
  else {
    cout << (s+"s") << endl;
  }


return 0;
}
///....


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	int pos[112];
	RC(i, 100){
		pos[i] = -1;
	}
	RC(i, 9){
		int tmp;
		cin >> tmp;
		pos[tmp] = i;
	}
	int a[3][3] = {0};
	int n;
	cin >> n;
	RC(i, n){
		int tmp;
		cin >> tmp;
		if(pos[tmp] != -1){
			((int *)a)[pos[tmp]] = 1;
		}
	}
	bool ans = false;
	if(a[0][0] && a[0][1] && a[0][2]) ans = true;
	if(a[1][0] && a[1][1] && a[1][2]) ans = true;
	if(a[2][0] && a[2][1] && a[2][2]) ans = true;
	if(a[0][0] && a[1][0] && a[2][0]) ans = true;
	if(a[0][1] && a[1][1] && a[2][1]) ans = true;
	if(a[0][2] && a[1][2] && a[2][2]) ans = true;
	if(a[0][0] && a[1][1] && a[2][2]) ans = true;
	if(a[2][0] && a[1][1] && a[0][2]) ans = true;
	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;
  int m; cin >> m;
  priority_queue<P, vector<P>, greater<>> que[n];
  rep(i, m) {
    int p, y; cin >> p >> y;
    p--;
    que[p].push(P(y, i));
  }
  
  vector<P> vec(m);
  rep(i, n) {
    int pos = 1;
    while(!que[i].empty()) {
      P pa = que[i].top(); que[i].pop();
      vec.at(pa.second) = P(i+1, pos);
      pos++;
    }
  }

  rep(i, m) {
    cout << setfill('0') << right << setw(6) << vec.at(i).first;
    cout << setfill('0') << right << setw(6) << vec.at(i).second;
    cout << '\n';
  }

}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vi A(N);
    cin >> A;

    map<int, int> idx;
    auto B = A;
    sort(ALL(B));
    REP(i, N) idx[B[i]] = i;

    int ans = 0;
    REP(i, N) {
        if (i % 2 != idx[A[i]] % 2) {
            ans++;
        }
    }
    cout << ans / 2 << endl;
    return (0^_^0);
}



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

int main(){
  int n; 
  cin>>n;
  vector<int> D(n);
  set<int> d;
  for(int i=0; i<n; i++){
    cin >> D[i];
    d.insert(D[i]);
  }

  cout << d.size() << endl;

  return 0;
}

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

typedef struct money1{
	
	int num;
	int riritsu;
	int kinri;
	double total;
}MONEY;

#define N 10000

int main() {
	
	int sum_bank;//テゥツ環?ィツ。ツ古ヲツ閉ー
	
	
	while(cin >> sum_bank){
		
		if(sum_bank == 0){
			break;
		}
		
		int year;
		double max;
		int num_bank = 0;
		
		cin >> year;
		
		MONEY sum[sum_bank];
		
		for(int i = 0;i < sum_bank;i++){
			
			cin >> sum[i].num >> sum[i].riritsu >> sum[i].kinri;
			
		}
		
		if(sum[0].kinri == 1){
			sum[0].total = N * (1 + ((year * sum[0].riritsu) / (double)100));
		}else if(sum[0].kinri == 2){
			sum[0].total = N * pow(1 + (sum[0].riritsu / (double)100) , year);
		}
		
		max = sum[0].total;
		num_bank = sum[0].num;
		
		
		
		for(int i = 1;i < sum_bank;i++){
			
			if(sum[i].kinri == 1){
				sum[i].total = N * (1 + (year * sum[i].riritsu / (double)100));
			}else if(sum[i].kinri == 2){
				sum[i].total = N * pow(1 + (sum[i].riritsu / (double)100) , year);
			}
			
			
			
			if(max < sum[i].total){
				max = sum[i].total;
				num_bank = sum[i].num;
			}
			
			
			
		}
		
		cout << num_bank << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    ll n;
    cin >> n;
    Combination com(n + 2);
    ll ans = com.fact(n - 1) * (n - 1);
    for(int i = n - 2; i >= (n + 1) / 2; i--){
        ans = (ans + MOD - com.com(i - 1, i * 2 - n) * com.fact(i) % MOD * com.fact(n - 1 - i) % MOD) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=50;
ll a,b,ans=1;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b;
	if(b<0){
		if((b-a)%2==1){
			cout<<"Positive"<<endl;
		}else{
			cout<<"Negative"<<endl;
		}
	}else if(a>0){
		cout<<"Positive"<<endl;
	}else{
		cout<<"Zero"<<endl;
	}
	return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> a)
{
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (a[a[i] - 1] == i + 1)
        {
            cnt++;
        }
    }
    cout << cnt / 2 << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,sumt,nowt;
string S;

int main(){
    cin>>N;
    int t[N];
    string s[N];
    rep(i,N){
        cin>>s[i]>>t[i];
        sumt+=t[i];
    }
    cin>>S;
    rep(i,N){
        nowt+=t[i];
        if(S==s[i])break;
    }
    out(sumt-nowt);
    
    
}


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

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

int main()
{
    int x;
    cin >> x;
    vi a{(x / 1000) % 10, (x / 100) % 10, (x / 10) % 10, x % 10};

    string exp;
    function<bool (int, int)> backtrack = [&](int level, int acc) {
        if (level == 4) {
            if (acc == 7) {
                cout << exp << "=7" << endl;
                return true;
            } else {
                return false;
            }
        }
        exp += "+" + to_string(a[level]);
        if (backtrack(level + 1, acc + a[level])) return true;
        exp.erase(exp.size() - 2);
        exp += "-" + to_string(a[level]);
        if (backtrack(level + 1, acc - a[level])) return true;
        exp.erase(exp.size() - 2);
        return false;
    };
    exp = to_string(a[0]);
    backtrack(1, a[0]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define nd second                   
#define fori(i, a, b, c) 	for (int i = (int)(a); i <= (int)(b); i += (int)(c))
#define ford(i, a, b, c) 	for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define MOD 998244353

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lol;
typedef vector<lol> vlol;

ifstream in ("input");

const int NR = 2e5 + 5;

int a, b;
int main()	{
	ios::sync_with_stdio(false);
	int i;
	cin >> a >> b;
	cout << a*(a-1)/2 + b*(b-1)/2;
}












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


int main(){
    int N;
    string S;
    cin >> N >> S;
    for(int i = 0; i < S.size(); ++i){
        char cnt = (S[i] - 'A' + N) % 26 + 'A';
        cout << cnt;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class MyUtil {
	public BufferedReader br;
	public MyUtil() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	public int getInt() throws IOException {
		return Integer.valueOf(br.readLine());
	}

	public int[] getIntArray(int N) throws IOException {
		int[] ret = new int[N];
		for (int i=0; i < N; ++i) {
			ret[i] = Integer.valueOf(br.readLine());
		}
		return ret;
	}

	public String getString() throws IOException {
		return br.readLine();
	}

	public String[] getSplitString(String delim) throws IOException {
		return br.readLine().split(delim);
	}

	public String[] getStringArray(int N) throws IOException {
		String[] ret = new String[N];
		for (int i=0; i < N; ++i) {
			ret[i] = br.readLine();
		}
		return ret;
	}
}

public class Main {
	public static void main(String[] args) throws IOException {
		new Tenka2019().c();
	}
}

class Tenka2019 {
	void c() throws IOException {
		MyUtil mu = new MyUtil();
		int N = mu.getInt();
		String S = mu.getString();
		int b = 0, w = 0;
		for (char c : S.toCharArray()) {
			if (c == '#') {
				b++;
			} else {
				w++;
			}
		}
		int ans = Math.min(b, w);
		int lb=0, rw = w;
		for (char c : S.toCharArray()) {
			if (c == '#') {
				lb++;
			} else {
				rw--;
			}
			ans = Math.min(ans, lb + rw);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27848
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> ac_pos;
  for(int i=1; i<N; i++){
    if(S[i-1] == 'A' && S[i]=='C') ac_pos.push_back(i-1);
  }
  // cout << " ac_pos: "; print_vec(ac_pos);
  for(int i=0; i<Q; i++){
    int l, r;
    cin >> l >> r;
    l--; r--;
    auto index1 = lower_bound(ac_pos.begin(), ac_pos.end(), l) - ac_pos.begin();
    auto index2 = lower_bound(ac_pos.begin(), ac_pos.end(), r) - ac_pos.begin();
    cout << index2 - index1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3876
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int H,W,h,w;
	cin >> H >> W >> h >> w;
	cout << (H-h)*(W-w) << endl;
}	


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

int main() {
    int k, x;
    cin >> k >> x;

    for (int i = x - k + 1; i <= x + k - 1; i++) {
        if (i != x - k + 1) {
            cout << " ";
        }
        cout << i;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256