akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = n - k + 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> h(n);
	int maxi = 0;
	for( auto &i : h ){
		cin >> i;
		maxi = max( maxi, i ); 
	}
	h.push_back(0);
	
	int cnt = 0;
	for( int z = 1; z <= maxi; ++z ){
		bool flag = false;
		for( int j = 0; j <= n; ++j ){
			if( z <= h[j] && !flag ){
				flag = true;
			}
			if( z > h[j] && flag ){
				flag = false;
				++cnt;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int a[100010],vis[100010],n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1,cnt=0;!vis[i];i=a[i],cnt++)
	{
		if (i==2)
		{
			printf("%d\n",cnt);
			return 0;
		}
		vis[i]=1;
	}
	printf("-1\n");
}

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

public class Main {

    public static void main(String[] args) {
        try {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArray = br.readLine().split("\\s");
        Integer[] intArray;
        intArray = new Integer[strArray.length];
        for (int i = 0; i < strArray.length; i++) {
            intArray[i] = Integer.valueOf(strArray[i]);
        }
        switch (intArray[0].compareTo(intArray[1])) {
            case 1:
                System.out.println("a > b");
                break;
            case -1:
                System.out.println("a < b");
                break;
            case 0:
                System.out.println("a == b");
                break;
        }
        
                } catch(IOException e) {
            System.err.println(e);
        }

    }
}

Measured memory_bytes: 17004
N = int(input())
heights = list(map(int, input().split()))
ans = 0
def water(h):
    global ans
    min_h = min(h)
    ans += min_h
    after_h = list(map(lambda x: x-min_h, h))
    len_ah = len(after_h)
    last_zero = -1
    zero_cnt = 0
    for i in range(len_ah):
        if after_h[i] == 0:
            if last_zero != i - 1:
                water(after_h[last_zero+1:i])
            last_zero = i
            zero_cnt += 1
    if last_zero != len_ah - 1:
        water(after_h[last_zero+1:])

water(heights)

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        long k = sc.nextLong();

        for (char c : s) {
            int num = Character.getNumericValue(c);

            if (num == 1 && --k == 0) {
                System.out.println(1);
                return;
            }

            if (num != 1) {
                System.out.println(num);
                return;
            }
        }

        System.out.println(1);

    }
}

Measured memory_bytes: 35816
#include <stdio.h>
#include <ctype.h>

int main(){

  int alphabet[26] = {};
  char ch;
  while(scanf("%c", &ch) != EOF){
	if(isalpha(ch)){
	  alphabet[tolower(ch) - 'a']++;
	}
  }
  for(int i = 0; i < 26; i++){
	printf("%c : ", i + 97);
	printf("%d\n", alphabet[i]);
  }
  return 0;
}


Measured memory_bytes: 2040
import sys

def bellman_ford(n, edges, source):
    """Bellman Ford algorithm

    n: int, the number of nodes.
    edges: list, [edge1, edge2, ... ]
           edge_i = [node, neighbour, weight of the edge]
    source: int, start node.
    """
    # Initializing the distance from source.
    inf = float('inf')
    dist=[inf for i in range(n)]
    dist[source] = 0

    # Relaxation step
    for i in range(n):
        for edge in edges:
            if dist[edge[1]] > dist[edge[0]] + edge[2]:
                dist[edge[1]] = dist[edge[0]] + edge[2]
                if i == n - 1 and edge[1] == n-1:
                    return -1

    return dist


def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    edges = []
    for _ in range(M):
        a, b, c = map(int, input().split())
        edges.append((a-1, b-1, -c))

    dist = bellman_ford(N, edges, 0)

    if dist == -1:
        return 'inf'
    else:
        return int(-dist[N-1])


if __name__ == '__main__':
    print(main())


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1000000007

using namespace std;

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

  rep(i, s.size() - 1) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }

    if (((i + 2) < s.size()) && (s[i] == s[i + 2])) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }

  cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
n = int(input())
s = list(input())
#print(s)

l = []
for i in range(1, n):
    a = s[0:i]
    b = s[i:]
#    print(a,b)
    x = []
    for j in range(len(a)):
        if a[j] in b:
            x.append(a[j])
    else:
        l.append(len(set(x)))
print(max(l))
            






Measured memory_bytes: 3060
n, k = map(int, input().split())
s = input()

slid = []
for i in range(n):
    if i == 0:
        slid.append(0)
        continue
    if s[i] != s[i-1]:
        slid.append(i-1)
        slid.append(i)
slid.append(n-1)

zone = []
for j in range(len(slid)//2):
    zone.append([slid[j*2], slid[j*2+1]])

front = s[0]
n_zone = len(zone)
if n_zone%2 == 0:
    n_zone0 = n_zone//2
elif front == "0":
    n_zone0 = (n_zone+1)//2
else:
    n_zone0 = (n_zone-1)//2

if n_zone0 <= k:
    print(n)
    exit()

ans = 0
if front == "1":
    now = 0
else:
    ans = zone[k*2-1][1]+1
    now = 1

while True:
    if now+k*2-1 >= n_zone:
        break
    ans = max(ans, zone[now+k*2-1][1]-zone[now][0]+1)

    if now+k*2 >= n_zone:
        break
    ans = max(ans, zone[now+k*2][1]-zone[now][0]+1)
    now += 2

print(ans)

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

long long int len1,len2,i,j,mat[3002][3002];
vector<char> vec;
int main()
{
    string str1,str2,temp="";
    
    cin>>str1;
    cin>>str2;
    len1 = str1.length();
    len2 = str2.length();
    for(i=0;i<=len1;i++)
    mat[0][i] = 0;
    for(i=0;i<len2;i++)
    mat[i][0] = 0;
    for(i=1;i<=len2;i++)
    {
        for(j=1;j<=len1;j++)
        {
            if(str2[i-1] == str1[j-1])
            {
                mat[i][j] = mat[i-1][j-1]+1;
            }
            else
            {
                mat[i][j] = max(mat[i-1][j],mat[i][j-1]);
            }
            
        }
    }
    // for(i=1;i<=len2;i++)
    // {
    //     for(j=1;j<=len1;j++)
    //     {
    //         cout<<mat[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    i = len2;
    j = len1;
    while(i>=1 && j>=1)
    {
        // cout<<"i = "<<i<<" j = "<<j<<endl;
        if(str2[i-1] == str1[j-1])
        {
            temp = temp + (str1[j-1]);
            i--;
            j--;
        }
        else if(mat[i][j] == mat[i-1][j])
        {
            i--;
        }
        else
        {
            j--;
        }
        
    }
    reverse(temp.begin(),temp.end());
    cout<<temp<<endl;
    // cout<<mat[len2][len1]<<endl;
}

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

int main() {
	int N;
	cin >> N;
	int X = 1 << N;
	string S;
	vector<vector<int> > P(N + 1, vector<int>(X));
	cin >> S;
	for (int i = 0; i < X; i++) cin >> P[0][i];
	for (int i = 0; i < N; i++) {
		int Y = 1 << i;
		for (int j = 0; j < X; j++) {
			int D = abs(P[i][j] - P[i][(j + Y) % X]);
			if (S[D - 1] == '0') P[i + 1][j] = min(P[i][j], P[i][(j + Y) % X]);
			else P[i + 1][j] = max(P[i][j], P[i][(j + Y) % X]);
		}
	}
	for (int i = 0; i < X; i++) {
		cout << P[N][i] << endl;
	}
}


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

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a>=3200) cout << s;
    else cout << "red";
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
dp=[[0]*n for i in range(n)]
for i in range(n-2,-1,-1):
    for j in range(n-1,i,-1):
        if j==n-1:
            if s[j]==s[i]:
                dp[i][j]=1
        else:
            if s[j]==s[i] and dp[i+1][j+1]+1<=j-i:
                dp[i][j]=dp[i+1][j+1]+1
            else:
                dp[i][j]=0
ans=0
for i in range(n):
    for j in range(n):
        ans=max(ans,dp[i][j])
print(ans)

Measured memory_bytes: 270140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll n; cin >> n;
	cout << n + sq(n) + sq(n)*n;

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


	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, A, B;
  cin >> K >> A >> B;
  int a = A % K;
  if(a == 0){
    cout << "OK" << endl;
  } else {
    a += B;
    a -= A;
    if(a >= K){
      cout << "OK" << endl;
    } else {
      cout << "NG" << endl;
    }
  }
}


Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int h, w; cin >> h >> w;
    vector<string> a(h);
    list(i,h) cin >> a[i];
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    list(i,h){
        list(j,w){
            if(a[i][j]=='#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }

    list(i,h){
        if(row[i]){
            list(j,w){
                if(col[j]) cout << a[i][j];
            }
            cout << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()
	a := make([]string, N)
	b := make([]string, M)
	for i := 0; i < N; i++ {
		a[i] = getString()
	}
	for i := 0; i < M; i++ {
		b[i] = getString()
	}
	//out(N, M, a, b)

	ans := "No"
	for i := 0; i <= N-M; i++ {
		for j := 0; j <= N-M; j++ {
			ok := true
		L0:
			for k := 0; k < M; k++ {
				for l := 0; l < M; l++ {
					//out(i, j, k, l, a[i+k][j+l], b[k][l])
					if a[i+k][j+l] != b[k][l] {
						//out("!=")
						ok = false
						break L0
					}
				}
			}
			if ok == true {
				ans = "Yes"
			}
		}
	}

	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <numeric>
#define M 1000000007
#define pb push_back
#define forz(i,s,n) for(lli i=s;i<n;i++)

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

typedef long long int lli;
//typedef pair<long long int, long long int> pll;
typedef unsigned long long int ull;
using namespace std;

lli recpow(lli x, lli n)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x) % M, n / 2);
    else //n is odd
        return (x * recpow((x * x) % M, (n - 1) / 2)) % M;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.second < b.second);
}

bool comp(pair<lli, lli> a, pair<lli, lli> b)
{
    if(a.first==b.first)
        return a.second<b.second;
    else
        return a.first<b.first;
}

void multiply(lli f[2][2], lli m[2][2])
{
    lli x = (f[0][0] % M * m[0][0] % M) % M + (f[0][1] % M * m[1][0] % M) % M;
    lli y = (f[0][0] % M * m[0][1] % M) % M + (f[0][1] % M * m[1][1] % M) % M;
    lli z = (f[1][0] % M * m[0][0] % M) % M + (f[1][1] % M * m[1][0] % M) % M;
    lli w = (f[1][0] % M * m[0][1] % M) % M + (f[1][1] % M * m[1][1] % M) % M;
    f[0][0] = x % M;
    f[0][1] = y % M;
    f[1][0] = z % M;
    f[1][1] = w % M;
}

lli u[2][2] = {{1, 1}, {1, 0}};

void power(lli f[2][2], lli n)
{
    if (n == 0 || n == 1)
        return;
    power(f, n / 2);
    multiply(f, f);
    if (n % 2 != 0)
        multiply(f, u);
}

lli fib(lli n)
{
    if (n == 1)
        return 2;
    else if (n == 2)
        return 3;
    else
    {
        lli h[2][2] = {{1, 1}, {1, 0}};
        power(h, n + 1);
        return h[0][0];
    }
}

//code begins here
int main()
{
    fast_io;
    lli n,k;
    cin>>n>>k;
    lli h[n];
    forz(i,0,n)
    cin>>h[i];
    lli dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    if(n<=k)
    {
        forz(i, 2, n)
        {
            dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
            forz(j, 0, i)
            {
                dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
            }
        }
        cout<<dp[n-1]<<endl;
        return 0;
    }
    forz(i,2,k+1)
    {
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        forz(j,0,i)
        {
            dp[i]=min(dp[i], dp[j]+abs(h[i]-h[j]));
        }
    }
    forz(i,k+1,n)
    {
        dp[i] =dp[i-1] + abs(h[i] - h[i - 1]);
        forz(j, i-k, i)
        {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    //cout<<dp[n-3]<<" "<<dp[n-2]<<endl;
    cout<<dp[n-1]<<endl;
    return 0;
}


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

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

}

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

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }
        
        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let n: usize = read_as_vec()[0];

    let a: Vec<usize> = read_as_vec();
    let b: Vec<usize> = read_as_vec();
    let c: Vec<usize> = read_as_vec();

    let mut prev_dish = n;
    let mut ans = 0;
    for dish_no in &a{
        if prev_dish + 1 == *dish_no{
            ans += c[prev_dish-1];
        }

        ans += b[*dish_no-1];
        prev_dish = *dish_no;
    }

    println!("{}", ans);
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

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

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


int main() {
  ll N; cin >> N;
  map<int, int> mp;
  rep(i, N) {
    int num; cin >> num;
    auto itr = mp.find(num);
    if(itr != mp.end()) {
      mp.erase(itr);
    } else {
      mp[num]++;
    }
  }
  dump(mp.size());
}

Measured memory_bytes: 4864
H, W, M = [int(i) for i in input().split()]

sum_h = [0] * W
sum_w = [0] * H
bomb_list = set()

for _ in range(M):
    h, w = [int(i) for i in input().split()]
    h -= 1
    w -= 1
    bomb_list.add((h,w))
    sum_h[w] += 1
    sum_w[h] += 1

max_sum_h = max(sum_h)
max_sum_w = max(sum_w)
output = max_sum_h + max_sum_w - 1

max_bombs_h = [h for h in range(H) if sum_w[h] == max_sum_w]
max_bombs_w = [w for w in range(W) if sum_h[w] == max_sum_h]

for h in max_bombs_h:
    for w in max_bombs_w:
        if (h, w) not in bomb_list:
            output = max_sum_h + max_sum_w
            break
        else:
            continue
        break
        
print(output)

Measured memory_bytes: 83412
s = input()
if s == "AKIHABARA" or s == "AKIHABAR" or s == "AKIHABRA" or s == "AKIHBARA" or s == "AKIHABR" or s == "AKIHBAR" or s == "AKIHBRA" or s == "AKIHBR":
    print("YES")
elif s == "KIHABARA" or s == "KIHABAR" or s == "KIHABRA" or s == "KIHBARA" or s == "KIHBRA" or s == "KIHBAR" or s == "KIHABR" or s == "KIHBR":
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <cstdio>

const int MAXN = 3005;

double p[MAXN], f[MAXN][MAXN];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);

    f[0][0] = 1;
    for (int i = 1; i <= n; i++) for (int j = 0; j <= i; j++) {
        f[i][j] = f[i - 1][j] * (1 - p[i]);
        if (j) f[i][j] += f[i - 1][j - 1] * p[i];
    }

    double ans = 0;
    for (int i = (n + 1) >> 1; i <= n; i++) ans += f[n][i];
    printf("%.9f\n", ans);
    
    return 0;
}

Measured memory_bytes: 68992
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n;
    cin >> n;
    vector<int> p(n+1);
    rep(i,n)cin >> p[i];
    int ans = 0;
    rep(i,n){
        if(p[i]==i+1){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if (N == M) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

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

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
LL x[1000], y[1000];
LL a[40];
mt19937_64 mt(123);

void genTest() {
    n = 1000;
    forn(i, n) {
        x[i] = y[i] = 0;
        unsigned long long chance = mt() % 101;
        forn(bit, 30) if (mt() % 100 < chance) {
            x[i] |= 1ll << bit;
        }
        chance = mt() % 101;
        forn(bit, 30) if (mt() % 100 < chance) {
            y[i] |= 1ll << bit;
        }
        if (abs(x[i] + y[i]) % 2 != abs(x[0] + y[0]) % 2) {
            ++x[i];
        }
    }
}

void readTest() {
    cin >> n;
    forn(i, n) {
        cin >> x[i] >> y[i];
        x[i] *= -1;
        y[i] *= -1;
    }
}

bool check() {
    forn(i, n) if (abs(x[i] + y[i]) % 2 != abs(x[0] + y[0]) % 2) {
        return false;
    }
    return true;
}

void getAnswer() {
    m = 32;
    forn(i, m) {
        a[i] = 1ll << (31 - i);
    }
    a[m++] = 1;
    a[m++] = 1;
    if (abs(x[0] + y[0]) % 2 == 0) {
        --m;
    }
}

string solve(LL x, LL y) {
    string res = "";
    forn(i, m) if (abs(x) > abs(y)) {
        if (x > 0) {
            x -= a[i];
            res.pb('L');
        } else {
            x += a[i];
            res.pb('R');
        }
    } else {
        if (y > 0) {
            y -= a[i];
            res.pb('D');
        } else {
            y += a[i];
            res.pb('U');
        }
    }
    assert(x == 0 && y == 0);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
//    forn(test, 12341234) {
//        genTest();
//        getAnswer();
//        forn(i, n) {
//            if (!solve(x[i], y[i])) {
//                cerr << x[i] << ' ' << y[i] << endl;
//                cerr << "test" << ' ' << test << endl;
//                cerr << "iter" << ' ' << i << endl;
//                return 0;
//            }
//        }
//        if (!(test & 1023)) {
//            cerr << "OK " << test << endl;
//        }
//    }
    readTest();
    if (!check()) {
        cout << -1 << endl;
        return 0;
    }
    getAnswer();
    cout << m << endl;
    forn(i, m) cout << a[i] << ' ';
    cout << endl;
    forn(i, n) {
        cout << solve(x[i], y[i]) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int n, g, x, y;
long long f = 1000000;
long long a[100000];
long long b[100000];
long long c[100000];
long long d[100000];
long long e[100000];
long long u[100000];
long long aa[100000];
long long bb[100000];
long long cc[100000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		aa[i] = a[i];
	}
	for (int i = 0; i < n; i++) {
		scanf("%lld", b + i);
		bb[i] = b[i];
	}
	std::sort(aa, aa + n);
	std::sort(bb, bb + n);
	for (int i = 0; i < n; i++) {
		if (aa[i] > bb[i]) {
			printf("No\n");
			return 0;
		}
	}
	for (int i = 0; i < n - 1; i++) {
		if (aa[i + 1] < bb[i]) {
			printf("Yes\n");
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cc[i] = b[i] * f + i;
		c[i] = a[i] * f + i;
	}
	std::sort(cc, cc + n);
	std::sort(c, c + n);
	for (int i = 0; i < n; i++) {
		d[c[i] % f] = i;
		e[i] = cc[i] % f;
	}
	for (int i = 0; i < n; i++) {
		u[i] = e[d[i]];
	}
	while (u[x]) {
		x = u[x];
		y++;
	}
	if (y == n - 1)printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
deque<int>l;
int n,w;
int main(){
    cin>>n;
    for(int i=n%2;i<n+n%2;i++){
        cin>>w;
        if(i%2==0)l.push_back(w);
        else l.push_front(w);
    }
    for(deque<int>::iterator i=l.begin();i!=l.end();i++)
    cout<<*i<<" ";
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint operator()(int n) { return fact[n]; }
};

int main() {
    lint X, Y;
    cin >> X >> Y;

    // a+2b = X
    // b+2a = Y
    // (a+b)*3 = X+Y

    // b+2(X-2b) = X
    // b+2X-4b = X
    // b+2X-4b = X

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    lint a = Y - (X + Y) / 3;
    lint b = X - (X + Y) / 3;

    if (a < 0 or b < 0) {
        cout << 0 << endl;
        return 0;
    }

    combination comb(10000000);

    cout << (comb.fact[a + b] * comb.ifact[a] * comb.ifact[b]).x << endl;

    return 0;
}

Measured memory_bytes: 159496
#include<bits/stdc++.h>
using namespace std;
bool visited[3][3];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int arr[3][3];
    memset(visited,sizeof(visited),false);
    /*for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cout<<visited[i][j]<<"w ";
        }
        cout<<"\n";
    }*/
    map<int,int>track;
    map<int,int>row;
    map<int,int>column;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
            track[arr[i][j]]++;
            row[arr[i][j]]=i;
            column[arr[i][j]]=j;

        }
    }
    int n;
    cin>>n;
    while(n--)
    {
        int a;
        cin>>a;
        //cout<<a<<"\n";
        if(track[a]!=0)
        {
            //cout<<a<<"im here"<<"\n";
            visited[row[a]][column[a]]=true;
        }

    }
    int r,c,d1,d2;
    
    //row check
    for(int i=0;i<3;i++)
    {
        r=0;
        for(int j=0;j<3;j++)
        {
            if(visited[i][j]==true)
            {
                //cout<<i<<" "<<j<<"\n";
            r++;
            }
        }
        if(r==3)
        {
            cout<<"Yes"<<"\n";
            return 0;
        }
    }
    //column check
    for(int i=0;i<3;i++)
    {
        c=0;
        for(int j=0;j<3;j++)
        {
            if(visited[j][i])
            c++;
        }
        if(c==3)
        {
            cout<<"Yes"<<"\n";
            return 0;
        }
    }
    //d1 check
    if (visited[0][0] && visited[1][1] && visited[2][2])
    {
        cout<<"Yes"<<"\n";
        return 0;
    }
    if(visited[0][2] && visited[1][1] && visited[2][0])
    {
        cout<<"Yes"<<"\n";
        return 0;
    }
    cout<<"No"<<"\n";
}

Measured memory_bytes: 3600
a,b=map(int,input().split())
hoge=input()
flag1=0
flag2=1
flag3=0
for i in range(a+b+1):
  if(hoge[i]=="-" and i<a):
    flag1=1
  if(hoge[i]=="-" and i==a):
    flag2=0
  if(hoge[i]=="-" and i>a):
    flag3=1

if(flag1==0 and flag2==0 and flag3==0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int N = 2000000000;

int even(const int a[],int x,int y){
	if(x==0){return a[x+1];}
	else if(x==y-1){return a[x-1];}
	else{return min(a[x-1],a[x+1]);}
}

int odd(const int a[],int x,int y){
	if(x==y-1){return a[x-1];}
	else{return max(a[x-1],a[x+1]);}
}


int main() 
{
	int n;
	while(cin>>n&&n!=0)
	{
		bool flag1=false;//連続してたらnone
		bool flag2=false;//x以外のところで大小が×だったらnone
		int count(0);//xの個数
		int a[1001]={};
		int b[1001]={};//i番目のxの入っている位置
		for(int i=0;i<n;i++)
		{
			string s;cin>>s;
			if(s[0]=='x'){a[i]=N;b[count]=i;count++;}
			else{sscanf(s.c_str(), "%d", &a[i]);}
			if(count>1&&b[count-1]==b[count-2]){flag1=true;}//2個連続でxならflag立て
		}
		
		for(int i=0;i<n-1;i++)
		{
			if(a[i]!=N&&a[i+1]!=N)
			{
				if(i%2==0)
				{
					if(a[i]>=a[i+1]){flag2=true;}
				}
				else
				{
					if(a[i]<=a[i+1]){flag2=true;}
				}
			}
		}
		
		if(flag1||flag2){cout<<"none"<<endl;}//flagが立っていたらnone
		else if(n==1){cout<<"ambiguous"<<endl;}//n=1ならambiguos
		else
		{
			int top(1000000003),bottom(-1000000003);
			for(int i=0;i<count;i++)
			{
				if(b[i]%2==0)
				{
					top=min(top,even(a,b[i],n));
				}
				else
				{
					bottom=max(bottom,odd(a,b[i],n));
				}
			}
			
			ll ans(0);
			ans +=top;
			ans -=bottom;

			if((ans)==2){cout<<top-1<<endl;}
			else if((ans)>2){cout<<"ambiguous"<<endl;}
			else if((ans)<2){cout<<"none"<<endl;}
		}
	}
	return 0;
}

Measured memory_bytes: 1280
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func main() {
	r := nextInt()
	fmt.Println(3 * r * r)
}


Measured memory_bytes: 640
import numpy as np
a,b,c = map(int,input().split())
L = np.array([a,b,c])
d = (L%2).sum()

def calc(a,b,c):
    e = a+b+c
    max1 = max(a,b,c)
    min1 = min(a,b,c)
    mid = e - max1 - min1
    return (max1*2 - mid - min1)//2
    
if d == 3 or d == 0:
    print(calc(a,b,c))
elif d == 1:
    if a%2 ==1:
        b +=1
        c +=1
        print(calc(a,b,c)+1)
    elif b%2 == 1:
        a +=1
        c +=1
        print(calc(a,b,c)+1)
    elif c%2 == 1:
        a +=1
        b +=1
        print(calc(a,b,c)+1)
elif d == 2:
    if a%2 == 0:
        b +=1
        c +=1
        print(calc(a,b,c)+1)
    elif b%2 == 0:
        a +=1
        c +=1
        print(calc(a,b,c)+1)
    elif c%2 == 0:
        a +=1
        b +=1
        print(calc(a,b,c)+1)
        



Measured memory_bytes: 20368
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
void solve()
{
    int n; cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int x= __gcd(j,k);
                sum+= __gcd(x,i);
            }
        }
    }
    
    cout<<sum;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test;test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
int main()
{	
	ll n, k;
	cin >> n >> k;
	ll ans = k;
	while(--n) {
	 	ans *= (k-1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

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

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?'){
      s[i] = 'D';
    }
  }
  cout << s << endl;

  return 0;
}


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

int main() {
    double n;
    for(int i=0;i<10000;i++){
        cin >> n;
        if(n==0){
            break;
        }
        vector<double>s(n);
        for(int i=0;i<n;i++){
            cin >> s.at(i);
        }
        double sum=0,m=0;
        for(int i=0;i<n;i++){
            sum+=s.at(i);
        }
        m=sum/n;
        double A=0,a=0,sub=0;
        for(int i=0;i<n;i++){
            A+=pow(s.at(i)-m,2.0);
        }
        a=sqrt(A/n);
        cout << fixed << setprecision(10);
        cout << a << endl;
    }
}


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

using namespace std;

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

    int n;
    cin>>n;

    vector<int> arr(n);

    for(int i=0;i<n;i++) cin>>arr[i];

    int q;
    cin>>q;

    while(q--)
    {
        int op,l,r;
        cin>>op>>l>>r;

        if(!op)
        {
            cout<<*min_element(arr.begin()+l,arr.begin()+r)<<endl;
        }else
        {
            cout<<*max_element(arr.begin()+l,arr.begin()+r)<<endl;
        }
    }


    return 0;
}



Measured memory_bytes: 3216
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int n;
ll ans;
char s[100005];
class Trie{
	public:
		Trie(){}
		~Trie(){}
		inline void get(){
			scanf("%lld",&l),cnt=0;
		}
		inline void insert(const int &n,char *s){
			int now=0,i;
			for(i=1;i<=n;++i){
				if(nxt[now][s[i]-'0']==0)nxt[now][s[i]-'0']=++cnt;
				now=nxt[now][s[i]-'0'];
			}
		}
		ll search(int x,int d){
			if(x==0&&d!=0)return (l-d+1)&(d-l-1);
			return search(nxt[x][0],d+1)^search(nxt[x][1],d+1);
		}
	private:
		ll l;int now,nxt[100005][2],cnt;	
}trie;
int main(void){
	register int i;
	scanf("%d",&n),trie.get();
	for(i=1;i<=n;++i)
		scanf("%s",s+1),trie.insert(strlen(s+1),s);
	ans=trie.search(0,0);
	if(ans==0)puts("Bob");
	else puts("Alice");
	return 0;
}

Measured memory_bytes: 4096
import java.io.*;
import java.util.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
int[] n=new int[5];
while((str=br.readLine())!=null){
String[] s=str.split(" ");
for(int i=0;i<5;i++){
n[i]=Integer.parseInt(s[i]);
}
Arrays.sort(n);
for(int i=5;i>1;i--){
System.out.print(n[i-1]+" ");
}
System.out.println(n[0]);
}
}
}

Measured memory_bytes: 17020
import numpy as np
S = input()
S_ = list(set(S))
S = np.array(list(S))
S_ = np.array(S_)
ans = 'Yes'
if len(S_)!=2:
    ans = 'No'
elif sum(S==S_[0])!=2:
    ans = 'No'

print(ans)

Measured memory_bytes: 20392
import java.util.*;

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();
	if ( (A < C && C < B) || (B < C && C < A) ) System.out.println("Yes");
	else System.out.println("No");
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int mod = 1e9 + 7;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int n ; cin >> n ; int dp[n+1] ; 
    dp[0] = 0, dp[1] = 0, dp[2] = 0 ;
    
    for(int i=3; i<=n; i++) {
        dp[i] = 1 ;
        for(int j=3; j<=i; j++) 
        dp[i] = (dp[i] + dp[i-j]) % mod ; 
    } 
    
    cout << dp[n] ;
    
    return 0 ;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	namespace impl
	{
		struct max_t
		{
			template<class T>constexpr T operator()(T&& lhs, T&& rhs)const
			{
				return std::max(lhs, rhs);
			}
		};
		struct min_t
		{
			template<class T>constexpr T operator()(T&& lhs, T&& rhs)const
			{
				return std::min(lhs, rhs);
			}
		};
	}
	constexpr impl::max_t max;
	constexpr impl::min_t min;

	template<class T>auto orderby(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min(); 

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	int N, M;
	std::cin >> N >> M;
	lib::graph_t edge(N);
	for (auto _ : boost::irange(M))
	{
		int a, b;
		std::cin >> a >> b;
		--a; --b;
		edge[a].emplace(b);
		edge[b].emplace(a);
	}
	std::queue<int> queue;
	std::vector<std::optional<int>> result(N);
	auto add = [&](int i, int p)
	{
		if (!result[i])
		{
			result[i] = p;
			queue.emplace(i);
		}
	};
	add(0, 0);
	while (queue.size())
	{
		auto i = queue.front();
		queue.pop();
		for (auto n : edge[i])
		{
			add(n, i);
		}
	}
	std::cout << "Yes" << std::endl;
	for (auto i : boost::irange(1, N))
	{
		std::cout << *result[i] + 1 << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 27652
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}


signed main()
{
    i64 A, B, K;
    cin >> A >> B >> K;

    set<i64> ans;
    for (int i = 0; i < K; ++i) {
        i64 x = A + i;
        i64 y = B - i;
        ans.emplace(x);
        ans.emplace(y);
    }

    for (i64 n : ans) {
        if (A <= n && n <= B) cout << n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from fractions import Fraction


def comb(n: int, k: int) -> int:
    if n < 0 or k < 0:
        pdt = 0
    else:
        pdt = 1
        for s in range(1, k + 1):
            pdt *= Fraction(n - s + 1, s)

    return pdt.numerator


N = int(input())

dic = {}
for i in range(N):
    s = sorted(input())
    s = "".join(s)
    dic.setdefault(s, 0)
    dic[s] += 1

ans = 0
for value in dic.values():
    ans += comb(value, 2)
print(ans)


Measured memory_bytes: 99924
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    
    string t[4] = {"AC", "WA", "TLE", "RE"};
    rep(i, 4) {
        cout << t[i] << " x " << mp[t[i]] << endl;
    }
    return 0;
}

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

int main() {
  int X;
  cin >> X;
  int M = -1;
  for (int i = 1; i <= X; i++) {
    for (int j = 2; j < 10; j++) {
      if (pow(i, j) <= X && pow(i, j) > M) M = pow(i, j);
    }
  }
  cout << M << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int main() {
    int i, n, num=0; 
    double debt = 100000;
    int k;
    scanf("%d", &n);
    
    if( n<0 || n>100)
        printf ("error");
    else
    {
        if( n==0 )
            debt = 100000;
        else
        {
            for(i=1; i<=n; i++)
            {
                debt = debt*(1.05);
                k = (int) debt % 1000;
                if( k == 0 )
                    num = ( (int) debt/1000)*1000;
                else
                    num = ( (int) (debt/1000)+1)*1000;
                debt = num;
            }

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


Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <string>
#define INF 100000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
typedef pair<int,int> P;
// #define int long long
/* define/include */

int main(){
  int H,W;
  string S[51];
  cin>>H>>W;
  for(int i=0;i<H;i++){
    cin>>S[i];
  }
  int c=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      c=0;
      if(S[i][j]=='.'){
        FOR(k,i-1,i+2){
          FOR(l,j-1,j+2){
            if(k<0||l<0)continue;
            if(S[k][l]=='#'){
              c++;
            }
          }
        }
        S[i][j]=c+48;
      }
    }
  }
  for(int i=0;i<H;i++){
    cout<<S[i]<<endl;
  }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
 
root = [-1]*n
def r(x):
    if root[x] < 0:
        return x
    else:
        root[x] = r(root[x])
        return root[x]
 
def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x
 
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)
 
ans = 0
for i in range(n):
    ans = max(ans, -root[i])
 
print(ans)

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

using namespace std;

const int N = 2e5 + 3;
const int mod = 998244353;

int n, q;
long long t[N * 4], b[N * 4], pf[N];

void push(int v, int tl, int tr) {
    if (!b[v]) return;
    if (tl != tr) {
        b[v << 1] = b[v];
        b[v << 1 | 1] = b[v];
    }
    t[v] = (pf[tr] - pf[tl - 1] + mod) % mod;
    t[v] = (t[v] * b[v]) % mod;
    b[v] = 0;
}

void upd(int l, int r, int val, int v = 1, int tl = 1, int tr = n) {
    push(v, tl, tr);
    if (l > tr || tl > r) return;
    if (l <= tl && tr <= r) {
        b[v] = val;
        push(v, tl, tr);
        return;
    }
    int tm = (tl + tr) >> 1;
    upd(l, r, val, v << 1, tl, tm);
    upd(l, r, val, v << 1 | 1, tm + 1, tr);
    t[v] = (t[v << 1] + t[v << 1 | 1]) % mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> q;
    pf[n] = 1;
    for (int i = n - 1; i >= 1; i--) {
        pf[i] = (pf[i + 1] * 10) % mod;
    }
    for (int i = 2; i <= n; i++) {
        pf[i] = (pf[i - 1] + pf[i]) % mod;
    }
    upd(1, n, 1);
    while (q--) {
        int l, r, x;
        cin >> l >> r >> x;
        upd(l, r, x);
        push(1, 1, n);
        cout << t[1] << endl;
    }
}

Measured memory_bytes: 13324
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 1000


int main() {
	int n, m, hh, k, t, p;
	int a[N];
	int b[N];
	int c[N];
	int h[N];
	int r[N];
	int l[N];
	int d[N];
	int us[N];
	int p2[10];
	bool used[10];
	int aa[600];
	int cost[30][110];
	int x, y, z, xx, yy, zz, ans;
	p2[0] = 1;
	f(i, 9)p2[i + 1] = p2[i] * 2;
	int fr, to;
	f(i, N) {
		a[i] = 0;
		b[i] = 0;
		c[i] = 0;
		h[i] = 0;
		r[i] = 0;
	}
	while(true) {
		ans = MOD;
		scanf("%d %d %d %d", &n, &m, &hh, &k);
		if ((n + m + hh + k) == 0)return 0;
		f(i, m) {
			scanf("%d %d %d %d %d", &a[i], &b[i], &c[i], &h[i], &r[i]);
			a[i]--;
			b[i]--;
			r[i]--;
		}
		scanf("%d %d", &fr, &to);
		fr--;
		to--;
		scanf("%d", &p);
		f(i, p) {
			scanf("%d %d", &l[i], &d[i]);
			us[i] = 0;
			f(j, l[i]) {
				scanf("%d", &x);
				us[i] += p2[x - 1];
			}
		}
		f(i, p2[k])aa[i] = MOD;
		aa[0] = 0;
		f(i, p) {
			for (int j = p2[k] - 1; j >= 0; j--) {
				x = (j | us[i]);
				aa[x] = min(aa[x], aa[j] + d[i]);
			}
		}
		f(ii, p2[k]) {
			if (aa[ii] < MOD) {
				x = ii;
				f(i, k) {
					if (x % 2 == 0)used[i] = true;
					else used[i] = false;
					x /= 2;
				}
				f(i, 30) {
					f(j, 110)cost[i][j] = MOD;
				}
				cost[0][fr] = 0;
				f(tim, hh) {
					f(i, m) {
						if ((tim + h[i]) <= hh) {
							if (used[r[i]]) {
								cost[(tim + h[i])][b[i]] = min(cost[(tim + h[i])][b[i]], cost[tim][a[i]] + c[i]);
								cost[(tim + h[i])][a[i]] = min(cost[(tim + h[i])][a[i]], cost[tim][b[i]] + c[i]);
							}
							else {
								cost[(tim + h[i])][b[i]] = min(cost[(tim + h[i])][b[i]], cost[tim][a[i]]);
								cost[(tim + h[i])][a[i]] = min(cost[(tim + h[i])][a[i]], cost[tim][b[i]]);
							}
						}
					}
					f(i, n) {
						cost[tim + 1][i] = min(cost[tim + 1][i], cost[tim][i]);
					}
				}
				f(i, n) {
					cost[hh][i] = min(cost[hh][i], cost[hh - 1][i]);
				}
				if (cost[hh][to] < MOD) {
					ans = min(ans, (cost[hh][to] + aa[ii]));
				}
			}
		}
		if (ans < MOD)printf("%d\n", ans);
		else printf("-1\n");
	}


	return 0;
}


Measured memory_bytes: 2640