akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<tuple>
#include<climits>
using namespace std;

int main(){
  priority_queue <tuple<int,int>,vector<tuple<int,int> >,greater<tuple<int,int> > > checkpoint;
  vector<vector<int> > path;
  vector<int> min_distance;
  int n;

  cin >> n;
  path.resize(n);
  for(int i=0;i<n;i++){
    path[i].resize(n);
    for(int j=0;j<n;j++){
      path[i][j]=INT_MAX;
    }
  }
  min_distance.resize(n);
  for(int i=0;i<n;i++){
    min_distance[i]=INT_MAX;
  }

  for(int i=0,from,to,cost,m;i<n;i++){
    cin >> from >> m;
    for(int j=0;j<m;j++){
      cin >> to >> cost;
      path[i][to]=cost;
    }
  }

  checkpoint.push(make_tuple(0,0));
  while(!checkpoint.empty()){
    int from=get<1>(checkpoint.top());
    int distance=get<0>(checkpoint.top());

    if(distance<min_distance[from]){
      min_distance[from]=distance;
      for(int i=0;i<n;i++){
        if(path[from][i]!=INT_MAX){
          checkpoint.push(make_tuple(path[from][i]+distance,i));
	}
      }
    }
    checkpoint.pop();
  }

  for(int i=0;i<n;i++){
    cout << i << " " << min_distance[i] << endl;
  }
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<pair<ll,ll>> tmp;
    for(i = 0;i < n;++i){
        if(s.at(i) == 'o') tmp.emplace_back(i, i + c);
    }
    ll last = -1;
    set<pair<ll,ll>> mae;
    for(i = 0;i < tmp.size();++i){
        if(tmp.at(i).first > last){
            last = tmp.at(i).second;
            mae.insert(tmp.at(i));
        }
    }
    if(mae.size() != k){
        return 0;
    }
    set<pair<ll,ll>> usiro;
    ll hazi = 1e9+7;
    for(i = tmp.size()-1;i >= 0;--i){
        if(tmp.at(i).second < hazi){
            hazi = tmp.at(i).first;
            usiro.insert(tmp.at(i));
        }
    }
    if(usiro.size() != k){
        return 0;
    }
    set<pair<ll,ll>> ans;
    set_intersection(all(mae), all(usiro), inserter(ans, ans.end()));
    for(auto x:ans){
        cout << x.first + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 42352
#include <iostream>

using namespace std;

int main(){
    long long int h,w,ans = 0;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }

    if((h*w)%2 == 0)
        ans = (h*w)/2;
    else 
        ans = ((h*w)/2)+1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# あああああああああああくそHとWぎゃくだ
W,H = list(map(int, sys.stdin.readline().split()))
P = [int(sys.stdin.readline()) for _ in range(W)]
Q = [int(sys.stdin.readline()) for _ in range(H)]

edges = []
for p in P:
    edges.append((p, 'P'))
for q in Q:
    edges.append((q, 'Q'))
edges.sort()

ans = 0
a = W + 1
b = H + 1
for e, pq in edges:
    if pq == 'P':
        ans += e * b
        a -= 1
    else:
        ans += e * a
        b -= 1
print(ans)


Measured memory_bytes: 26300
integer N
integer,allocatable,dimension(:)::x,y
integer(16),allocatable,dimension(:)::h
integer(16) height
logical check
read*,N
allocate(X(N),Y(N),H(N))

do i=1,N
  read*,x(i),y(i),h(i)
end do

do i=0,100
  do j=0,100
    check=.true.
    do k=1,N
      if(h(k)==0)cycle
      height=h(k)+abs(i-x(k))+abs(j-y(k))
    end do
    do k=1,N
      if(h(k)/=max(height-abs(i-x(k))-abs(j-y(k)),0))check=.false.
    end do
    if(check)then
      print"(i0,A,i0,A,i0)",i," ",j," ",height
    endif
  end do
end do
end

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	int N,M;
	cin >> N >> M;
	vector<string> A(N), B(M);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N - M + 1; i++) {
		for (int j = 0; j < N - M + 1; j++) {
			int c = 0;
			for (int k = i; k < M + i; k++) {
				for (int l = j; l < M + j; l++) {
					if (A[k][l] != B[k - i][l - j])break;
					c++;
					if (c == M*M) {
						cout << "Yes" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

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

    if (S == U)
    {
        A--;
    } else
    {
        B--;
    }
    cout << A << " " << B << endl;
    
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [ [ int(x) for x in input().split()] for _ in range(M) ]

ab.sort(key=lambda x:x[1])

t = ab[0][1]
ans = 1 

for (a, b) in ab:
    if a >= t:
        ans += 1
        t = b

print(ans)


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

const int N=100005;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int a;
        cin>>a;
        cout<<a+a*a+a*a*a<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import sys
from operator import mul
from functools import reduce
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

def com(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(readline())
if n < 3:
    print(0)
    sys.exit()

ans = 0
for i in range(1,n//3+1):
    num = n - i * 3
    ans += com(num+i-1,i-1) % 1000000007
    ans %= 1000000007

print(ans)
    


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

#define Online 1
// #define multitest 1
#define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
	ll r,x,d;
	cin >> r >> d >> x;
	for(int i=0;i<10;++i)
	{
		x = r*x - d;
		cout << x << '\n';
	}
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

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

#define int long long
int n,m,ans;

signed main(){
  cin>>n>>m;
  if(n==1&&m==1)
    return cout<<1<<endl,0;
  if(n==1){
    return cout<<m-2<<endl,0;
  }
  if(m==1){
    return cout<<n-2<<endl,0;
  }
  if((m-2)*(n-2)>0)
    ans+=(m-2)*(n-2);
  return cout<<ans<<endl,0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        if ((10 * g + b) % 4 == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    int amin = 1000000000;
    for (int i = 0; i < n; i++)
    {
        int buf;
        cin >> buf;
        h[i] = buf;
    }
    sort(h.begin(), h.end());
    for (int i = 0; i < n - k + 1; i++)
    {
        amin = min(amin, abs(h[i] - h[i + k - 1]));
    }

    cout << amin;
    /* code */
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		long d=sc.nextLong();

		long v1 = b/c-(a-1)/c;
		long v2 = b/d-(a-1)/d;
		long cd = lcm(c,d);
		long v3 = b/cd-(a-1)/cd;
		System.out.println(b-(a-1)-(v1+v2-v3));
		sc.close();
	}

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

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


Measured memory_bytes: 35636
N, X, M = map(int, input().split())
mod_appeared = [False] * M
A_cycle = [X]
mod_appeared[X] = True
A = X * X % M
while not mod_appeared[A]:
    A_cycle.append(A)
    mod_appeared[A] = True
    A = A * A % M


if N < len(A_cycle):
    print(sum(A_cycle[:N]))
    exit()

cycle_start = A_cycle.index(A)
cycle_len = len(A_cycle) - cycle_start
cycle_sum = sum(A_cycle[cycle_start:])
prefix_sum = sum(A_cycle[:cycle_start])

q, r = divmod(N - cycle_start, cycle_len)
ans = prefix_sum + q * cycle_sum + sum(A_cycle[cycle_start:cycle_start + r])
print(ans)


Measured memory_bytes: 68920
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    vector<int>dp(n+1);
    arep(i,1,n+1){
        dp[i]=INF;
        int money=1;
        while(i-money>=0){
            dp[i]=min(dp[i],dp[i-money]+1);
            money*=6;
        }
        money=1;
        while(i-money>=0){
            dp[i]=min(dp[i],dp[i-money]+1);
            money*=9;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
x, y = map(int, input().split())
ans = 0
if x == 1 and y == 1:
  print(1000000)
else:
  if x == 1:
    ans += 300000
  elif x == 2:
    ans += 200000
  elif x == 3:
    ans += 100000
  if y == 1:
    ans += 300000
  elif y == 2:
    ans += 200000
  elif y == 3:
    ans += 100000
  print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

#define FOR(_i, s, e) for(_i = s; _i < e; ++_i)
#define FOR_INV(_i, s, e) for(_i = e - 1; _i >= s; --_i)

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


using pos = std::pair<LONG, LONG>;



int main(){
    LONG i, j, k;
    LONG A;
    string B;

    cin >> A >> B;

    LONG BL = 0;
    LONG n = B.size();
    LONG factor = 1;
    FOR_INV(i, 0, n){
        if(B[i] == '.'){
            continue;
        }
        BL += (B[i] - '0') * factor;
        factor *= 10;
    }

    LONG r = A * BL;
    cout << r / 100;
}



//int main(){
//    LONG N, S;
//    cin >> N >> S;


//}


Measured memory_bytes: 3592
use std::io;
use std::cmp;
use std::collections::BinaryHeap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

const MOD: u64 = 1_000_000_007;

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let h = line[0];
    let w = line[1];
    let k = line[2];

    let mut p = vec![vec![0; w+2]; w+2];
    let mut q = vec![0u64; w+2];
    q[0] = 1;
    q[1] = 1;
    for i in 0..w {
        q[i+2] = q[i+1] + q[i] % MOD;
    }

    for i in 1..w+1 {
        for j in 1..w+1 {
            if i+1 == j {
                p[i][j] = q[i-1] * q[w-j] % MOD;
            } else if i==j+1 {
                p[i][j] = q[w-i] * q[j-1] % MOD;
            } else if i==j {
                p[i][i] = q[w-i] * q[i-1] % MOD;
            }
        }
    }

    let mut memo = vec![vec![0; w]; h + 2];
    memo[0][0] = 1;

    for i in 0..h {
        for t in 0..w {
            for j in 0..w {
                memo[i+1][t] += memo[i][j] * p[j+1][t+1] % MOD;
                memo[i+1][t] %= MOD;
            } 
        }
    }
    println!("{}", memo[h][k-1]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
ll a, b, n;
ll solve(ll x)
{
	return (a * x) / b - a * (x / b);
}
int main()
{
#if DEBUG_Switch
	freopen("C:\\code\\input.txt", "r", stdin);
#endif
	//freopen("C:\\code\\output.txt","r",stdin);
	a = readll();
	b = readll();
	n = readll();
	// repd(i, 0, n)
	// {
	// 	printf("%d %lld\n", i, solve(i) );
	// }
	ll ans = solve(min(b - 1, n));
	printf("%lld\n", ans );
	return 0;
}




Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = Integer.parseInt(scan.next());
        long d = Integer.parseInt(scan.next());
        long max = d*d;

        int ans = 0;
        for (int i = 0; i < n; i++) {
            long x = Integer.parseInt(scan.next());
            long y = Integer.parseInt(scan.next());
            if (x*x+y*y <= max) {
                ans++;
            }
        }
        scan.close();

        System.out.println(ans);
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  ll k;
  cin >> s >> k;
  
  ll notone = s.size()-1;
  rep(i, 0, (ll)s.size()) {
    if(s[i]-'0' != 1) {
      notone = i;
      break;
    }
  }
  ll ans = 0;
  if(k < notone+1) ans = 1;
  else ans = s[notone]-'0';
  cout << ans << "\n";
}

Measured memory_bytes: 256
#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;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
const int N=100005;
const int inf=1e18;
const double eps=1e-9;

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

int power(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
            res=res*a;
            res%=mod;
        }
        a=a*a;
        a%=mod;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    int a[n];
    for(int x=0;x<n;x++){
        cin>>a[x];
    }
    sort(a,a+n);
    int ans=0;
    for(int x=0;x<n;x++){
        for(int y=x+1;y<n;y++){
            if(a[x]==a[y]){
                continue;
            }
            for(int z=y+1;z<n;z++){
                if(a[y]==a[z]){
                    continue;
                }
                if(a[x]+a[y]>a[z]){
                    ans++;
                }
            }
        }
    }
    cout<<ans;








	
return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,z,l,n,m,a,r,f;
  long long min,max,sum;
  string s;
  //vector<vector<int>> A(n, vector<int>(m, 0));
  //vector<int> b(m);

  while(1){
    cin >> n >> x;
    if(n == 0 && x == 0)break;
    sum = 0;
    for(int i = 1;i <= n-2;i++){
      for(int j = i+1; j <= n-1; j++){
        for(int k = j+1; k <= n; k++){
          if(i+j+k == x)sum++;
        }
      }
    }
    cout << sum << endl;
  }
  
}


Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 100050

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

int n;
int a;
int arr[MAXN];
int main() {
  GI(n);
  FORN(i, n) {
    GI(arr[i]);
  }

  int idx = 0;
  int cnt = 0;
  while (idx < n) {
    if (arr[idx] == idx + 1) {
      swap(arr[idx], arr[idx+1]);
      cnt++;
    }
    idx++;
  }

//  FORN(i, n+1) { printf("%d ", arr[i]); } printf("\n");

  printf("%d\n", cnt);
  return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 4e5 + 9, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;



int main(){
    init();

    int R;  cin >> R;
    cout << fixed << setprecision(10) << 2 * PI * R;

}

Measured memory_bytes: 3792
s = list(str(input()))
ans = 0
slen = len(s)
if len(s) % 2 == 1:
    pres = s[0:len(s)//2]
    lass = s[len(s)//2+1:slen]
else:
    pres = s[0:len(s)//2]
    lass = s[len(s)//2:slen]
lass=lass[::-1]
for i in range(slen//2):
    if pres[i] == lass[i]:
        pass
    else:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>

int main() {
	int inputan1{}, inputan2{}, inputan3{}, Inputan[3]{}, max;
	std::cin >> inputan1 >> inputan2 >> inputan3;
	Inputan[0] = 10 * inputan1 + inputan2 + inputan3;
	Inputan[1] = 10 * inputan2 + inputan1 + inputan3;
	Inputan[2] = 10 * inputan3 + inputan1 + inputan2;
	for (int i{0}; i <= 2; i++) {
		if (Inputan[i] >= max) {
			max = Inputan[i];
		}
	}
	std::cout << max;
	return 0;
}

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

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;}

int main(){ 
  map<ll,ll> mp;
  ll n;
  cin >> n;
  ll tmp;
  rep(i,n){
    cin >> tmp;
    mp[tmp] ++;
  }

  ll m = distance(mp.begin(), mp.end());
  if(n==m){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}



Measured memory_bytes: 12800
fn main() {
    let (a, b) = input();

    println!("{} {}", a * b, a * 2 + b * 2);
}

fn input() -> (i32, i32) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut i = s.trim().split_whitespace().map(|q| q.parse::<i32>().unwrap());

    (i.next().unwrap(), i.next().unwrap())
}



Measured memory_bytes: 5024
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d; 
    cout << max({a*c,a*d,b*c,b*d}) << endl;
}

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

const double PI = acos(-1.0);

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ha = (h*60 + m)/720*(PI*2);
    double ma = m/60*(PI*2);
    double angle = ha - ma;
    double ans = sqrt(a*a+b*b-2.0*a*b*cos(angle));
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    int n , k;
    cin>>n>>k;
    vector<int>vec(n);
    for(int i =0 ; i < n ; i++ ) cin>>vec[i];
    for(int i = 0 , j = k ; j < n; j++, i++ ) {
        if(vec[j] > vec[i]) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3988
import operator

n = int(input())
series = list(map(int, input().split()))

frame = [0]*21

def new_frame(shift):
    global frame
    if shift == 0:
        new_frame = list(map(operator.mul, frame, [2]*21))
    else:
        plus = [0]*shift + frame[:-shift]
        minus = frame[shift:] + [0]*shift
        new_frame = list(map(operator.add, plus, minus))
    return new_frame

frame[series[0]] = 1

for i in range(1,n-1):
    frame = new_frame(series[i])
else:
    print(frame[series[-1]])


Measured memory_bytes: 5680
s=gets.chomp
l=0
r=s.size-1
k=0
while l<r
	if s[l]!=s[r]
		if s[l]=='x'
			l+=1
		elsif s[r]=='x'
			r-=1
		else
			p -1;exit
		end
		k+=1
	else
		l+=1
		r-=1
	end
end
p k

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    bool ok=false;
    rep(i,s.size()){
        if (s[i]=='9'){
            ok=true;
            break;
        }
    }
    if (ok){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


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

int main() {
	int n;
  	cin >> n;
  	vector<int> h(n);
    int max = 0;
  
  for(int i = 0; i < n; i++){
  	cin >> h.at(i);
  }
  
  for(int j = 0; j < n; j++){
  
  int i = j;
  int num = 0;
  while(i < n){
    if(i == n-1){
      break;
    }else if(h.at(i) < h.at(i+1)){
      break;}
    i++;
    num++;
  }
  j = i;
  if(num > max){
  max = num;
  }
  }
  cout << max << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n){
    int a;
    cin >> a;
    mp[a]++;
  }
  int ans = 0;
  rrepit(itr, mp){
    int i = itr->first;
    int j = (1 << ((int)log2(i) + 1)) - i;
    int add = 0;
    if(i == j){
      add = itr->second/2;
      itr->second -= add*2;
    }else{
      add = min(itr->second, mp[j]);
      itr->second -= add;
      mp[j] -= add;
    }
    ans += add;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 67720
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  char c;
  ll day,i,cnt=0;
  int ck=0;
  cin>>s;
  cin>>day;
  for(i=0;i<s.size();i++)
  {
      if(s[i]=='1')
      {
          cnt++;
          ck=1;
      }
      else
      {
          c = s[i];
          break;
      }
  }

  if(day<=cnt&&ck)
  {
      cout<<1<<endl;
  }
  else
    cout<<c<<endl;


}


Measured memory_bytes: 256
//Payment
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    long long N;
    cin >> N;
    long long ans = (1000 - (N % 1000));
    cout << (ans == 1000 ? 0 : ans) << endl;
    return 0;
}

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

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vec(i) vector<i>
#define all(c) c.begin(), c.end()
#define FOR(i, s, e) for(int i=s; i<e; i++)
#define mod 1000000007LL
#define endl "\n"

template <typename T> void print(T v);
template <typename T> void print(vector<T> a);

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

    print(abs(a-1));
}

int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t=1;
while(t--)solve();
return 0;
}
template <typename T>
void print(T v){
    cout<<v<<"\n";
}
template <typename T>
void print(vector<T> a){
    FOR(i, 0, a.size()){
        cout<<a[i]<<" ";
    }cout<<"\n";
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(n&1){
        cout<<"No"<<endl;
        return 0;
    }
    bool ans=true;
    for(int i=0;i<n-1;++++i){
        if(s[i]!='h'||s[i+1]!='i'){
            ans=false;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, R;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> R;

	if (10 <= N) cout << R << endl;
	else cout << (R + 100 * (10 - N)) << endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 0x3f3f3f3f
#define pll pair<long long , long long>
const int MAX=5e6+9;
const ll mod=998244353;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int n , cnt=0;
int t[MAX] , vis[MAX];
void dfs(int u){
    vis[u]=1;
    cnt = cnt+1;
    for(auto v:adj[u]){
        if(!vis[v]){
            dfs(v);
        }
    }
}
void dfs2(int x, int u){
    vis[x]=1;
    t[x]=u;
    for(auto v:adj[x]){
        if(!vis[v])
            dfs2(v, u);
    }
}
int main() 
{
    cin>>n;
    set<int> st;
    pair<int  , int > p[n+1];
    int res[n+1];
    for(int i=0;i<n;i++){
        cin>>p[i].first>>p[i].second;
        res[p[i].second]=i;
    }
    sort(p , p+n);
    for(int i=0;i<n;i++){
        int now= p[i].second;
        while(!st.empty() and p[i].second>(*st.begin())){
            adj[res[p[i].second]].push_back(res[(*st.begin())]);
            adj[res[(*st.begin())]].push_back(res[p[i].second]);
            now = min(now ,(*st.begin()));
        //    cout<<(*st.begin())<<endl;
            st.erase(st.begin());
        }
       // cout<<endl;
        st.insert(now);
    }
    for(int i=0;i<n;i++){
        if(!vis[i]){
            dfs(i);
            t[i]=cnt;
            cnt = 0;
        }
    }
    memset(vis, 0, sizeof(vis));
    for(int i=0;i<n;i++){
        if(!vis[i]){
            dfs2(i, t[i]);
        }
    }
    for(int i=0;i<n;i++)
        cout<<t[i]<<endl;
 
	
}


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

const int MX = 105;
int f[MX];

int main() {
	int a, b, c, ans = 0;
	cin >> a >> b >> c;
	ans++;
	f[a]++;
	if(f[b] == 0) ans++;
	f[b]++;
	if(f[c] == 0) ans++;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ALL(a) a.begin(),a.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define MAX 
using namespace std;

int n,m;
ll dp[155][80][10],INF=1000000000000000LL;
vector<int> x[155],d[155];

void solve(){
 for(;;){
  cin>>n>>m;
  if(!n&&!m) break;
  int kk,xx,dd;
  FOR(i,n){
   cin>>kk;
   FOR(j,kk){
    cin>>xx>>dd;
    x[i+1].pb(xx);
    d[i+1].pb(dd);
   }
  }
  FOR(i,155) FOR(j,80) FOR(k,10) dp[i][j][k]=INF;
  FOR(i,m+1) FOR(j,x[n].size()) dp[n][i][j]=0LL;
  for(int i=n-1;i>0;i--){
   FOR(j,m+1){
    FOR(k,x[i].size()){
     if(j){
      if(i==n-1) dp[i][j][k]=0;
      else{
       FOR(l,x[i+2].size()){
        dp[i][j][k]=min(dp[i][j][k],dp[i+2][j-1][l]+(ll)(d[i][k]+d[i+2][l])*abs(x[i][k]-x[i+2][l]));
       }
      }
     }
     FOR(l,x[i+1].size()){
      dp[i][j][k]=min(dp[i][j][k],dp[i+1][j][l]+(ll)(d[i][k]+d[i+1][l])*abs(x[i][k]-x[i+1][l]));
     }
    }
   }
  }
  ll mi=INF;
  FOR(i,x[1].size()) mi=min(mi,dp[1][m][i]);
  if(m) FOR(i,x[2].size()) mi=min(mi,dp[2][m-1][i]);
  cout<<mi<<endl;
  FOR(i,155){
   x[i].clear(); d[i].clear();
  }
 }
}

int main(){
 solve();
 return 0;
}

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

int main()
{
	int n;
	cin>>n;
	double t,a;
	cin>>t>>a;
	double temp=0.0,mini=INT_MAX,arr[n+1],index;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		temp=(double)t-(double)(arr[i]*(0.006));
		if(mini>(double)abs((double)a-temp)){
			mini=(double)abs((double)a-temp);
			index=i+1;
		}
	}
	cout<<index<<"\n";
	return 0;
}


Measured memory_bytes: 256
package main             
 
 import (
     "fmt"
 )
 
 func main() {
     var fw, fh, w, h, n int
     fw = 0
     fh = 0
     fmt.Scan(&w, &h, &n)
     for i := 0; i < n; i++{
         var x, y, i int
         fmt.Scan(&x, &y, &i)
         switch i {
         case 1:
             if fw < x {
                 fw = x
             }
         case 2:
           if x < w {
                w = x
            }
        case 3:
            if fh < y {
                fh = y
            }
        case 4:
            if y < h {
                h = y
            }
        }
    }
    val1 := w - fw
    val2 := h - fh
    if val1 < 0 {
        val1 = 0
    }
    if val2 < 0 {
        val2 = 0
    }
    fmt.Println(val1 * val2)
}                              

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readS(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		Q = Integer.parseInt(strArr[1]);
	}

	int Q;

	public void readS(String str) {
		CNT = new int[N + 1];
		CNT[1] = 0;
		for (int i = 1; i < N; i++) {
			CNT[i + 1] = CNT[i];
			if (str.charAt(i - 1) == 'A' && str.charAt(i) == 'C') {
				CNT[i + 1]++;
			}
		}
	}

	int[] CNT;

	public boolean hasNext() {
		// return cnt < N;
		return cnt < Q;
	}

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		int l = Integer.parseInt(strArr[0]);
		int r = Integer.parseInt(strArr[1]);
		System.out.println((CNT[r] - CNT[l]));
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 48508
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const MAX: usize = 100000;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut cnt = vec![0usize; MAX+1];
    let mut sum = 0;
    for _ in 0..N {
        let A: usize = sc.get();
        cnt[A] += 1;
        sum += A;
    }
    let Q: usize = sc.get();
    for _ in 0..Q {
        let B: usize = sc.get();
        let C: usize = sc.get();
        let t = cnt[B];
        cnt[B] = 0;
        cnt[C] += t;
        sum -= B * t;
        sum += C * t;
        println!("{}", sum);
    }
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	int good = 0, bad = 0;
	vector<int> pen(n+1);
	for(int i = 0; i < m; i++) {
		int p;
		string verdict;
		cin >> p >> verdict;
		if(verdict == "AC") {
			if(pen[p] == -1) continue; // solved already
			else {
				bad += pen[p];
				pen[p] = -1;
				good++;
			}
		} else {
			if(pen[p] == -1) continue;
			else {
				pen[p]++;
			}
		}
	}
	
	
	cout << good << ' ' << bad << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
	cout.setf(ios::fixed);
	cout.precision(10);

	double d;
	cin >> d;

	double ans = max(d, 2.0 * d / sqrt(2.0));
	if(1 <= d) ans = max(ans, 1.0 + floor(d));
	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1288
#include<stdio.h>
int main(void){
  int H,W;
  do{
    int i,j;
    scanf("%d %d",&H,&W);
    if(H==0&&W==0||300<H||300<W)
      return 0;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        if(i%2==0&&j%2==0||i%2!=0&&j%2!=0)
          printf("#");
        else
          printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }while(H!=0||W!=0);
  return 0;
}

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

typedef long long ll;
const ll mod=1e9+7;
const ll N=20003;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	bool ok=false;
	int n,cnt=0;
	cin>>n;
	while(n--){
		int d1,d2;
		cin>>d1>>d2;
		if(d1==d2) cnt++;
		else cnt=0;
		if(cnt==3) ok=true,cnt=0;
	}
	cout<<(ok?"Yes":"No");
}	  


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
    long long a;
    long long b;
    long long x;
    //if (scanf("%I64d %I64d %I64d", &a, &b, &x) < 3) return 0;
    if (scanf("%lld %lld %lld", &a, &b, &x) < 3) return 0;

    long long ans = b / x;
    if (a == 0LL)
    {
        ans++;
    }
    else
    {
        ans -= (a - 1LL) / x;
    }

    //printf("%I64d\n", ans);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	cout << max({a+b,a-b,a*b});
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,K; cin >> N >> K;
    VL A(N);
    REP(i,N) cin >> A[i];

    REP(i,N-K){
        if(A[i] < A[i+K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}

Measured memory_bytes: 4780
#include<cstdio>


using namespace std;
int main(void)
{
	double a;
	double b = 1;
	scanf("%lf",&a);
	for(double i = 1;i <= a;i++)
	{
		b = b * i;
	}
	printf("%.0lf\n",b);
	return 0;
}

Measured memory_bytes: 1080
// problem: "https://atcoder.jp/contests/abc127/tasks/abc127_b"

import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);

        int r = in.nextInt();
        int D = in.nextInt();
        int x = in.nextInt();

        int i;
        for(i=0;i!=10;i++)
        {
            x = r*x-D;
            System.out.println(x);
        }
    }
}


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

using namespace std;

int main() {

    string s;
    cin >> s;
    set<char> set;

    for(int i = 0; i < 4; i++) {
        set.insert(s[i]);
    }

    if(set.size() == 2) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

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

long long N;
long long P[200005];
long long pos[200005];
//              num, not pos
long long memo[200005];


long long dp(long long num){
	if(memo[num] != 0)
		return memo[num];
	if(pos[num] < pos[num+1]){
		memo[num] = dp(num+1) + 1;
		return memo[num];
	}
	return 1;
}


int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		cin >> P[i];
		pos[P[i]] = i;
	}
	long long maxi = 0;
	for(long long i = 0; i < N; i++){
		maxi = max(maxi, dp(P[i]));
	}

	cout << N - maxi << endl;
}

Measured memory_bytes: 8064
#include<stdio.h>
int a[100001],sum;//懒得改成防伪标识了QAQ~
void abcd(int l,int r)//快排部分详解（老套路，见at2823我的题解）
{int i=l,j=r,t;
int p=a[(l+r)/2];//相当于mid
while(i<=j)//循环不说了
{
    while(a[i]<p)
    {i++;}
    while(a[j]>p)
    {j--;}
    if(i<=j)
    {t=a[i]; 
    a[i]=a[j]; 
    a[j]=t;
    i++; 
    j--;}}//处理交换
    if(l<j)
    abcd(l,j);//继续拆分
    if(i<r)
    abcd(i,r); //这里数组我开成全局了所以不需要传参
    }
    int main()
    {   
    int i,n,m;  
    scanf("%d%d",&n,&m);   
    for(i=1;i<=n;i++)   
    scanf("%d",&a[i]);   
    abcd(1,n);  
    for(i=n;i>n-m;i--) //这里n到n-m是因为我是升序，若是降序就是1~m了  
    sum+=a[i];
    printf("%d\n",sum);//回车
    return 0;   
    }

Measured memory_bytes: 128