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

using ll = long long;
//typedef long long ll;

#define INF (1LL << 31 - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

inline bool check(int ux, int uy, int x, int y) {
  return (0 <= x and x < ux and 0 <= y and y < uy);
}

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

#define int long long

int n;
vector<int> a;

signed main() {
  cin >> n;
  a.resize(n);
  rep(i,n) {
    cin >> a[i];
  }

  int ans = 1;

  rep(i,n) {
    if (a[i] % 2 == 0) {
      ans *= 2;
    }
    else {
      ans *= 1;
    }
  }

  ans = pow(3, n) - ans;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf n;
    cin >>n;
    vector<intf> a(n);
    rep(i,n) cin >>a[i];

    cout << *std::max_element(a.begin(),a.end()) - *std::min_element(a.begin(),a.end()) <<endl;
}

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

using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        X[i] = x - 1;
    }

    sort(X.begin(), X.end());
    int pmin = X[0];
    int pmax = X[X.size()-1];

    int minval = 1e9;
    for(int p = pmin; p <= pmax; p++){
        int val = 0;
        for(int i = 0; i < N; i++){
            val += (X[i] - p) * (X[i] - p);
        }
        if(val < minval) minval = val;
    }

    cout << minval << endl;
    return 0;
}


Measured memory_bytes: 3520
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()

    val graph = Array(N, { mutableListOf<Int>()})
    (1..N-1).forEach {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        graph[a-1].add(b-1)
        graph[b-1].add(a-1)
    }

    fun dFrom(source: Int) : IntArray {
        val default = -1
        val d = IntArray(N, { default })
        val queue : Queue<Int> = ArrayDeque()
        queue.add(source)
        d[source] = 0
        while (!queue.isEmpty()) {
            val current = queue.poll()
            graph[current].forEach {
                if (d[it] == default) {
                    d[it] = d[current] + 1
                    queue.add(it)
                }
            }
        }
        return d
    }
    val dFromS = dFrom(0)
    val dFromT = dFrom(N -1)

    var fennec = 0
    var snuke = 0
    for (i in 0 until N) {
        if (dFromS[i] <= dFromT[i]) {
            fennec++
        } else {
            snuke++
        }
    }
    if (fennec > snuke) {
        println("Fennec")
    } else {
        println("Snuke")
    }
}

Measured memory_bytes: 80676
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n=sc.nextInt(),count=0;
	  String s="";
	  for(int i=1;i<=n;i++) {
		  s=String.valueOf(i);
		  if(s.length()%2!=0)count++;
	  }

	  System.out.println(count);
  }
}


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

class UnionFind
{
  public:
    vector<ll> Parent;

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

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

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

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

        return true;
    }
};

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

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

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

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

void solve(long long N)
{
    set<pair<int, int>> ans;

    bool m[N][N];
    for (int i = 1; i <= N; i++)
    {
        for (int j = i; j <= N; j++)
        {
            if (i != j)
            {
                ans.insert(make_pair(i, j));
            }
        }
    }

    if (N % 2 == 0)
    {
        for (int i = 1; i <= N; i++)
        {
            ans.erase(make_pair(i, N + 1 - i));
            ans.erase(make_pair(N + 1 - i, i));
            // m[i][N-i-1] = false;
            // m[N-i-1][i] = false;
        }
    }
    else
    {
        for (int i = 1; i <= N - 1; i++)
        {
            ans.erase(make_pair(i, N - i));
            ans.erase(make_pair(N - i, i));
            // m[i][N-i-2] = false;
            // m[N-i-2][i] = false;
        }
    }

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

    for (auto &&i : ans)
    {
        cout << i.first << " " << i.second << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <array>
#include <algorithm>

auto read = [](auto &x){std::cin >>x;};
auto readSeq = [](auto *begin, auto *end){
                  std::for_each(begin, end, read);
                };
auto printSeq = [](auto *begin, auto *end){
                   std::for_each(begin, end-1, [](auto x){std::cout<<x<<" ";});
                   std::cout << *(end-1) <<  std::endl;
                 };

int swapSort(int *begin, int *end);

int main ()
{
  int n;
  const int max_n = 100;
  std::array<int, max_n> arr;

  read(n);
  readSeq(arr.begin(), arr.begin()+n);

  auto cnt = swapSort(arr.begin(), arr.begin()+n);


  printSeq(arr.begin(), arr.begin()+n);
  std::cout << cnt << std::endl;

  return 0;
}

int swapSort(int *begin, int *end)
{
  auto swap = [](auto &a, auto &b){
                auto tmp = a;
                a = b;
                b =tmp;
              };

  auto n = std::distance(begin, end);
  auto itr = begin;

  auto cnt = 0;

  for (int i=0; i<n; i++)
    {
      auto min_i = i;
      for (int j=i+1; j<n; j++)
        {
          if (itr[j] < itr[min_i])
            {
              min_i = j;
            }
        }
      if (i != min_i){
        swap(itr[i], itr[min_i]);
        cnt++;
      }
    }

  return cnt;
}



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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  char d = 'a' - 'A';
  cout << (char) (s1[0] - d) << (char) (s2[0] - d) << (char)(s3[0] - d) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/

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

    rep(i, n + 1){
        rep(j, m + 1){
            count = i * (m - j) + j * (n - i);
            if(count == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*

状態が頂点と時間だけであれば、最小時間を求めるダイクストラ法だが、、、？

今回状態として、時間、銀貨、頂点の場所が存在する。
推移条件は　
移動：v -> u  s -= A, time += B
両替：v -> v  s += C, time += D

状態を
dp[v][s]: 頂点v, 所持金sにおける時間とする
sは10^9まであると思われがちだが、実はs <= N*運賃Aの最大値として問題ない。

また、状態が二次元になっただけで、
推移の中で議論する値timeが減少するような推移は存在しないのでダイクストラ法は使用できる。
*/

struct Edge {
    int to;
    int a;
    ll b;
    Edge(int to, int a, ll b): to(to), a(a), b(b) {}
};
struct Chg {
    ll c;
    ll d;
    Chg(ll c, ll d) : c(c), d(d) {}
};
struct Data {
    int v;
    ll coin;
    ll time;
    Data(int v, ll coin, ll time):  v(v), coin(coin), time(time) {}
    bool operator<(const Data& a) const {
        return time>a.time;
    }
};
const int n_max = 55;
const int a_max = 55;
vector<Edge> root[n_max];
vector<Chg> exc;
const int coin_limit = n_max*a_max;
//vector<vector<ll>> dp(n_max, vector<ll>(coin_limit, INF));
ll dp[n_max][coin_limit] = {0};

void dijkstra(int top, int s, map<int, ll> &ans){
    rep(i, n_max)rep(j, coin_limit){
        dp[i][j] = INF;
    }
    priority_queue<Data> pq;
    auto push = [&](int v, int coin, ll time){
        if (dp[v][coin] < time) return;
        dp[v][coin] = time;
        pq.emplace(v, coin, time);
    };
    push(top, s, 0);
    set<int> node;
    while(!pq.empty()){
        auto now = pq.top(); pq.pop();
        for (auto next: root[now.v]){
            int remain = now.coin - next.a;
            ll time = now.time + next.b;
            if (remain < 0) continue;
            if (dp[next.to][remain] <= time) continue;
            push(next.to, remain, time);
        }
        int r = now.coin + exc[now.v].c;
        r = min(r, coin_limit);
        ll t = now.time + exc[now.v].d;
        if (dp[now.v][r] > t){
            push(now.v, r, t);
        }

//        cout << now.v << ":" << now.coin  << ":" << now.time << endl; 

        if (ans.find(now.v) == ans.end()){
            ans.insert({now.v, now.time});
        }
    }

}

int main(){
    int n, m, s;
    cin >> n >> m >> s;
    rep(i, m){
        int u,v,a;
        ll b;
        cin >> u >> v >> a >> b;
        u--; v--;
        root[u].emplace_back(v,a,b);
        root[v].emplace_back(u,a,b);
    }
    rep(i, n){
        ll c, d;
        cin >> c >> d;
        exc.emplace_back(c, d);
    }

    map<int, ll> ans;
    dijkstra(0, min(s, coin_limit), ans);

    rep(i, n){
        if (i==0) continue;
        // ll ans1 = INF;
        // rep(j, coin_limit){
        //     ans1 = min(ans1, dp[i][j]);
        // }
        // cout << ans1 << endl;
        cout << ans[i] << endl;
    }

}



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

typedef long long ll;

struct UnionFind
{
    int i;
    vector<int> par;
    vector<int> size;
    UnionFind(int n): par(n),size(n,1){
        for(i = 0;i < n;++i){
            par.at(i) = i;
        }
    }
    
    int root(int x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = root(par.at(x));
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }else{
            if(size.at(x) < size.at(y)){
                swap(x,y);
            }
            par.at(rx) = ry;
            size.at(rx) += size.at(ry);
            return;
        }
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int get_size(int x){
        return size.at(root(x));
    }
};

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;

    UnionFind uf(n);
    for(i = 0;i < m;++i){
        int x,y,z;
        cin >> x >> y >> z;
        --x;    --y;
        uf.unite(x,y);
    }
    vector<int> tmp(n);
    for(i = 0;i < n;++i){
        tmp.at(i) = uf.root(i);
    }
    set<int> ans;
    for(i = 0;i < n;++i){
        ans.insert(tmp.at(i));
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 6144
trget_num = 753
x = list(input())
list_len = len(x)
uv = list(map(int, x))

list_len = len(uv)
min_heigt = 1000
for x in range(list_len-2):
    nagasa = abs(trget_num - (uv[x] * 100 + uv[x+1] * 10 + uv[x + 2]))
    if min_heigt > nagasa:
        min_heigt = nagasa

print(min_heigt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Pll complex<int>
#define X real()
#define Y imag()
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f


int32_t main()
{
	string s;
	cin >> s;
	if(s[2] == s[3] and s[4] == s[5])
		puts("Yes");
	else
		puts("No");
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


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


rep(i,s.size()){
    char c='A'+((s[i]-'A')+N)%26;
    cout<<c;
}


 return 0;
}
/*
2
ABCXYZ

CDEZAB

0
ABCXYZ

ABCXYZ

13
ABCDEFGHIJKLMNOPQRSTUVWXYZ

NOPQRSTUVWXYZABCDEFGHIJKLM
*/

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	m := make(map[int]int)
	for i := range a {
		fmt.Scan(&a[i])
		m[a[i]]++
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 512
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from collections import defaultdict

def x(a):
    return(a * (a - 1) / 2)

n = int(input())
d = defaultdict(int)
for i in range(n):
    w = input()
    ws = sorted(w)
    ww = ''.join(ws)
    d[ww] += 1

ans = 0
for i in d.keys():
    if d[i] > 1:
        ans += x(d[i])

print(int(ans))


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

using namespace std;

typedef unsigned long long ull;

const ull P1=9973;
const ull P2=1e8+7;

int r1,r2,c1,c2;

const int N=1e3+10;
int mat[N][N],pat[N][N];
ull cal[N][N];
ull Hash;

vector<pair<int,int> > ans;

void getPatHash()
{
    Hash=0;
    for(int i=0;i<r2;i++)
    {
        ull tmp=0;
        for(int j=0;j<c2;j++)
        {
            tmp=tmp*P1+pat[i][j];
        }
        Hash=Hash*P2+tmp;
    }
}

void go()
{
    ull tmp,base;
    for(int i=0;i<r1;i++)
    {
        tmp=0;
        base=1;
        for(int j=0;j<c1&&j<c2;j++)
        {
            tmp=tmp*P1+mat[i][j];
            base=base*P1;
        }
        cal[i][0]=tmp;
        for(int j=c2;j<c1;j++)
        {
            tmp=tmp*P1-mat[i][j-c2]*base+mat[i][j];
            cal[i][j-c2+1]=tmp;
        }
    }
    for(int j=0;j+c2<=c1;j++)
    {
        tmp=0;
        base=1;
        ull temp;
        for(int i=0;i<r1&&i<r2;i++)
        {
            tmp=tmp*P2+cal[i][j];
            base=base*P2;
        }
        temp=cal[0][j];
        cal[0][j]=tmp;
        if(cal[0][j]==Hash){
            ans.push_back(make_pair(0,j));
        }
        for(int i=r2;i<r1;i++)
        {
            tmp=tmp*P2-temp*base+cal[i][j];
            temp=cal[i-r2+1][j];
            cal[i-r2+1][j]=tmp;
            if(cal[i-r2+1][j]==Hash)
            {
                ans.push_back(make_pair(i-r2+1,j));
            }
        }
    }

}

int main()
{
    scanf("%d %d",&r1,&c1);

    char ch;

    for(int i=0;i<r1;i++)
    {
        getchar();
        for(int j=0;j<c1;j++)
        {
            ch=getchar();
            mat[i][j]=ch;
        }
    }

    scanf("%d %d",&r2,&c2);

    for(int i=0;i<r2;i++)
    {
        getchar();
        for(int j=0;j<c2;j++)
        {
            ch=getchar();
            pat[i][j]=ch;
        }
    }

    getPatHash();

    go();

    sort(ans.begin(),ans.end());

    for(int i=0;i<ans.size();i++)
    {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

    return 0;
}



Measured memory_bytes: 20792
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        decimal a, b;
        a = decimal.Parse(input[0]);
        b = decimal.Parse(input[1]);
        Console.WriteLine("{0:D}",(long)Math.Floor(a*b));
    }
}

Measured memory_bytes: 27568
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N, K; cin >> N >> K;
		if ((N + 1) / 2 < K) cout << "NO" << endl;
		else cout << "YES" << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
	ll n, m, x;
	cin >> n >> m >> x;
	ll ans = INF;
	vector<ll> c(n);
	vector<vector<ll>> a(n, vector<ll>(m));
	rep(i,n){
		cin >> c[i];
		rep(j,m){
			cin >> a[i][j];
		}
	}
	rep(bit,1<<n){
		ll sum = 0;
		vector<ll> b(m);
		rep(i, n)
		{
			if(bit&(1<<i)){
				sum += c[i];
				rep(j,m){
					b[j] += a[i][j];
				}
			}
		}
		bool ng = false;
		rep(i, m)
		{
			if(b[i]<x){
				ng = true;
			}
		}
		if(!ng){
			chmin(ans, sum);
		}
	}
	if(ans!=INF)cout << ans;
	else
		cout << -1;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    int  n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        v[i] = v[i] - 1 + k;
        v[i] %= k;
    }
    int dp[n+1];
    dp[0] = 0;
    map<int, int> m;
    m[0] = 1;
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        dp[i+1] =(dp[i] + v[i])%k;
        if(i+1 >= k)
        {
            ans += m[dp[i+1-k]] - 1;
            m[dp[i+1-k]]--;
        }
        m[dp[i+1]]++;
    }
    for(auto const& x: m)
    {
        int val = x.second;
        ans += (val*(val-1))/2;
    }
    cout << ans <<"\n";



    return 0;
}



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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;
static const bool DEBUG = false;

signed main() {
	int N; cin >> N;
	vector<int> a(N);
	unordered_map<int, bool> m;
	rep(i, 0, N) {
		cin >> a[i];
	}
	vector<int> b = a;
	sort(all(a));
	rep(i, 0, N) {
		if (i % 2)m[a[i]] = true;
		else m[a[i]] = false;
	}
	int ans = 0;
	rep(i, 0, N) {
		if (i % 2) {
			if (!m[b[i]]) {
				ans++;
			}
		}
		else {
			if (m[b[i]]) {
				ans++;
			}
		}
	}
	ans /= 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5156
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, n = list(map(int, readline().split()))

    x = min(b - 1, n)

    ans = int(a*x/b)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61776
#include<iostream>
#include<cmath>
#include<cstdio>
#include<iomanip>
using namespace std;
#define PI 3.141592653589793
int main(void){
    int a,b,C;
    double S,L,h,x;
    
    cin >> a >> b >> C;
    x = C * PI / 180;
    S = (a * b * sin( x )) / 2;
    L = a + b + (sqrt(a * a + b * b - 2 * a * b * cos( x )));
    h = 2 * S / a;
    
    std::cout << std::fixed << std::setprecision(5) << S << endl << L << endl << h << endl;
}


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


int main(){
    ll A[3][3];
    string ans = "No";
    for(ll i = 0; i < 3; i++){
        for(ll j = 0; j < 3; j++){
            cin >> A[i][j];
        }
    }
    ll n;
    cin >> n;
    for(ll i = 0; i < n; i++){
        ll b;
        cin >> b;
        for(ll i = 0; i < 3; i++){
            for(ll j = 0; j < 3; j++){
                if(A[i][j] == b) A[i][j] = -1;
            }
        }
    }

    for(ll i = 0; i < 3; i++){
        if(A[i][0] == A[i][1] && A[i][1] == A[i][2] && A[i][0] == -1) ans = "Yes";
    }

    for(ll i = 0; i < 3; i++){
        if(A[0][i] == A[1][i] && A[1][i] == A[2][i] && A[0][i] == -1) ans = "Yes";
    }

    if(A[0][0] == A[1][1] && A[1][1] == A[2][2] && A[0][0] == -1) ans = "Yes";
    if(A[0][2] == A[1][1] && A[1][1] == A[2][0] && A[0][2] == -1) ans = "Yes";

    cout << ans << endl;




    




    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < K; i++){
			int d = sc.nextInt();
			for(int j = 0; j < d; j++){
				A[sc.nextInt()-1]++;
			}
		}
		int count = 0;
		for(int r : A){
			if(r == 0){
				count++;
			}
		}
		System.out.print(count);
	}
}


Measured memory_bytes: 46232
program D

  implicit none
  integer(8) H
  integer(8) Monsters
  integer i
  integer sum
  read *, H
  sum = 0
  Monsters = 1
  do i = 1, 40
    H = H / 2
    ! print *, Monsters,H
    if ( H == 0 ) then
      ! print *, i
      Monsters = i
      exit
    end if
    Monsters = Monsters + 2**i
  end do
  print '(i0)', 2 **Monsters -1

end program


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = RLong();
            long[] moveN = new long[5];

            for (int i = 0; i < moveN.Length; i++)
            {
                moveN[i] = RLong();
            }

            long min = moveN.Min();
            long res = (n % min == 0) ? n / min : n / min + 1;
            Console.WriteLine(res + 4);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::string S){
    ll ans = 1;
    rep(i, N-1){
        if(S.at(i)!= S.at(i+1))
            ans ++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int i=1; i<=10001; i++) {
            if(Math.floor(i * 0.08) == a && Math.floor(i*0.1) == b) {
                System.out.println(i);
                return ;
            }
        }
        System.out.println(-1);



    }



}


Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#include<cstdio>
#include<cstring>
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                pe[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;
}
map<int , int >mp;
set<int  > st;
multiset<string> :: iterator it;
deque <char> q ;
int vis [10000000];
pair<int,int> a[2020];
int main()
{
    fast ;
     ll n;
     cin >> n;
   char ar[28];
   char a ='a';

     for ( int i=0;i<26;i++)
     {
         ar[i] = a;
         a++;
     }
     if(n<=26)
     {
      cout << ar[n -1]<<endl;
      return 0;
     }
     string s = "";
     while (n)
     {
        n--;
         ll x = n%26;
         s+=ar[x];
         n/=26;
     }
     reverse(s.begin(),s.end());
     cout << s <<endl;
}






Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
#define ll long long
using namespace std;
int a;
string s;
int main()
{
	fast;
	cin>>a>>s;
	if (a>=3200)
	   cout<<s<<endl;
	else
	   cout<<"red\n";
	return 0;
}

Measured memory_bytes: 256
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[-1]+A[i])
for j in range(m):
    b.append(b[-1]+B[j])
ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k -a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 47516
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int N,W;
int w[110],v[110];
ll dp[110][100010] = {0};

void input(){
    cin >> N >> W;
    for(int i=0;i<N;i++) cin >> w[i] >> v[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<N;i++){
        for(int sum_w=0;sum_w<=W;sum_w++){
            if(sum_w - w[i] >= 0){
                chmax(dp[i+1][sum_w], dp[i][sum_w-w[i]]+v[i]);
            }
            chmax(dp[i+1][sum_w], dp[i][sum_w]);   
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if(a.second == b.second){
        return a.first < b.first;
    }
    return a.second < b.second;
}
int main()
{
    fio;
    ll n, m;
    cin >> n >> m;
    for(int i = 1; i <= 100000; i ++){
        ll k = (i * 8) / 100;
        ll kk = (i * 10) / 100;
        if(k == n && kk == m){
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] argv){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		System.out.println((c>a?(c>b?(b>a?"Yes":"No"):"No"):"No"));
	}
}

Measured memory_bytes: 26336
#include"cstdio"
#include"cstring"
#include"iostream"
#include"algorithm"
using namespace std;

const int mod=1e9+7,MAX=4e3+5,MAXN=2e5+1,TT=2e3+1;
const long long inv2=5e8+4;

struct p{
    int a,b;
}a[MAXN];
int n;
long long ans;
long long c[MAX][MAX],cc[MAX][MAX];

int main()
{
    scanf("%d",&n);cc[1][1]=1;
    for(int i=1;i<=n;++i) scanf("%d%d",&a[i].a,&a[i].b),++c[TT-a[i].a][TT-a[i].b];
    for(int i=1;i<MAX;++i) for(int j=1;j<MAX;++j) if(i!=1||j!=1) cc[i][j]=(cc[i-1][j]+cc[i][j-1])%mod,c[i][j]=(c[i][j]+c[i-1][j]+c[i][j-1])%mod;
    for(int i=1;i<=n;++i) ans=(ans+c[TT+a[i].a][TT+a[i].b]-cc[a[i].a+a[i].a+1][a[i].b+a[i].b+1]+mod)%mod;
    printf("%lld\n",ans*inv2%mod);
    return 0;
}

Measured memory_bytes: 252416
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

// key，親，左の子，右の子の情報を持った構造体Nodeを設定
struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;  // ポインタ構造体Nodeのroot，NILを設定

void insert(int k)
{
    Node *y = NIL;  // yをNIL(zの親候補)
    Node *x = root;  // xをrootとする(現在の節点)
    Node *z;  // これから挿入するつもりの節点

    // zのメモリ領域を確保し，key, left, rightを設定する
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    // x(現在の節点)に関する処理
    // xがleafになるまで続ける
    while(x != NIL) {
        y = x;  // zの親としてxをyに代入
        if (z->key < x->key) {
            // xをxの左の子とする
            x = x->left;
        } else {
            // xをxの右の子とする
            x = x->right;
        }
    }

    // y(zの親候補)に関する処理
    z->parent = y;  // zの親をyとする
    if (y == NIL) {  // yがNIL(xがNIL)ならばrootはz
        root = z;
    } else {  // そうでないとき
        if (z->key < y->key) {
            // yの左の子をzとする
            y->left = z;
        } else {
            // yの右の子をzとする
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    // 中間順巡回
    if (u == NIL) {
        return;
    }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    // 先行順巡回
    if (u == NIL) {
        return;
    }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int n, m;
vector<vector<int>> G;

int dp[100100];
int rec(int v){
	if(dp[v] != -1) return dp[v];
	int res = 0;
	for(auto nv: G[v]){
		chmax(res,rec(nv)+1);
	}
	return dp[v] = res;
}
int main()
{
	cin >> n >> m;
	G.assign(n,vector<int>());
	rep(i,m){
		int x, y;
		cin >> x >> y;
		--x,--y;
		G[x].push_back(y);
	}
	rep(v,n){
		dp[v] = -1;
	}

	int res = 0;
	rep(v,n){
		chmax(res,rec(v));
	}
	cout << res << endl;

}


Measured memory_bytes: 11152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}



Measured memory_bytes: 20540
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    string s;cin>>s;
    ll ans=0;
    for(ll i=0;i<ll(s.size());i++)ans+=(s[i]=='1');
    cout<<ans;
}





Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

ans = 0
s = 0
ans2 = 0
s2 = 0
plus = True
for i in a:
    s += i
    s2 += i
    if plus:
        if s <= 0:
            ans += 1 - s
            s = 1
        if s2 >= 0:
            ans2 += s2 + 1
            s2 = -1
    else:
        if s >= 0:
            ans += s + 1
            s = -1
        if s2 <= 0:
            ans2 += 1 - s2
            s2 = 1

    plus = not plus

print(min(ans, ans2))


Measured memory_bytes: 14468
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <unordered_set>

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    int ans = 0;
    For(i, n) if(a[a[i]-1]-1 == i) ans ++;
    Cout(ans / 2);
}





Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    vector<vector<int>> dub(60, vector<int>(n));
    for(int i = 0; i < n; i++) {
        dub[0][i] = a[i];
    }
    for(int i = 1; i < 60; i++) {
        for(int j = 0; j < n; j++) {
            dub[i][j] = dub[i - 1][dub[i - 1][j]];
        }
    }
    ll now = 0;
    int i = 0;
    while(k) {
        if(k % 2) {
            now = dub[i][now];
        }
        k /= 2;
        i++;
    }
    cout << now + 1 << endl;
}

Measured memory_bytes: 51828
import java.io.IOException;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] d = new int[n];
		boolean[] checked = new boolean[n];
		for(int i = 0; i < n; i++) {
			d[i] = sc.nextInt() / 10;
			checked[i] = false;
		}
		
		boolean ans = true;
		PriorityQueue<Integer> task = new PriorityQueue<Integer>(Collections.reverseOrder());
		task.add(0);
		boolean flag = false;
		while(!task.isEmpty()) {
			int x = task.poll();
			if(x == n - 1) {
				flag = true;
				task.clear();
				break;
			}
			if(!checked[x]) {
				for(int j = x + 1; j <= Math.min(x + d[x], n - 1); j++) {
					task.add(j);
				}
				checked[x] = true;
			}
		}
		ans &= flag;
		
		for(int i = 0; i < n; i++) {
			checked[i] = false;
		}
		flag = false;
		
		task = new PriorityQueue<Integer>();
		task.add(n - 1);
		while(!task.isEmpty()) {
			int x = task.poll();
			if(x == 0) {
				flag = true;
				break;
			}
			if(!checked[x]) {
				for(int j = x - 1; j >= Math.max(x - d[x], 0); j--) {
					task.add(j);
				}
				checked[x] = true;
			}
		}
		ans &= flag;
		
		String answer = ans? "yes" : "no";
		System.out.println(answer);
	}
}


Measured memory_bytes: 106040
N=int(input())
W=[]
count=0
for i in range(N):
	w=str(input())
	W.append(w)
for i in range(N):
	c=0
	for j in range(N):
		if W[i]==W[j]:
			c=c+1
		if c>=2 and count==0:
			print("No")
			count=1
for i in range(N-1):
	s=0
	for j in W[i+1]:
		s=s+1
		if s==1:
			t=j
		for k in W[i]:
			r=k
	if t!=r and count==0:
		print("No")
		count=2
if count==0:
	print("Yes")

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <unordered_map>
using namespace std;
using ll = long long;
int main() {
  ll N, ans{};
  cin >> N;
  unordered_map<string, int> m;
  string S;
  while (cin >> S) {
    sort(begin(S), end(S));
    ans += m[S]++;
  }
  cout << ans << endl;
}


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

using namespace std;

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

int in() { int x; scanf("%d", &x); return x; }
template<typename T> void pv(T a, T b) { for (T i = a; i < b; i++) cout << *i << ' '; cout << endl; }
template<typename T, typename U> void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void chmax(T &x, U y) { if (x < y) x = y; }

int main() {
  int N = in();
  int a[2][110];
  int dp[2][110];

  REP(i,N) a[0][i] = in();
  REP(i,N) a[1][i] = in();

  REP(i,N) dp[0][i] = dp[1][i] = 0;

  dp[0][0] = a[0][0];
  dp[1][0] = a[0][0] + a[1][0];
  REP(i,N-1) {
    dp[0][i+1] = dp[0][i] + a[0][i+1];
    dp[1][i+1] = max(dp[0][i+1], dp[1][i]) + a[1][i+1];
  }

  // REP(i,N) cout << dp[0][i] << ' '; cout << endl;
  // REP(i,N) cout << dp[1][i] << ' '; cout << endl;

  cout << dp[1][N-1] << endl;

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int cntr = 0;
  for(int i=0;i<N;i++){
    if(s[i] == 'R') cntr++;
  }

  if(cntr > N / 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    long long n;

    cin >> n;

    n = ceil(sqrt(8 * n + 1)) - 1;

    cout << (n >> 1) + (n & 1);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, d, n, k, x,l;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Good";

    cin  >> a >> b >> c;
    ll before = 0;

    ans = min(a+b, min(b+c, c+a));

    std::cout << ans << endl; 
    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256