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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n;
    cin >> n;

    list<int> l;
    bool flgpush = true;
    bool flgreverse = true;

    int a;
    for(int in=0;in<n;in++) {
        cin >> a;
        if(flgpush) {
            l.push_front(a);
        }
        else {
            l.push_back(a);
        }

        if(flgpush) {
            flgpush = false;
        }
        else {
            flgpush = true;
        }

        if(flgreverse) {
            flgreverse = false;
        }
        else {
            flgreverse = true;
        }
        cout << endl;
    }

    if(flgreverse) l.reverse();
    for(auto itr=l.begin();itr!=l.end();itr++) {
        cout << *itr << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 9876
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
using namespace std;

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

int main() {
  string str;
  cin >> str;
  int q;
  cin >> q;
  string com;
  for(int i = 0; i < q; i++) {
    cin >> com;
    if(com == "replace") {
      int a, b;
      cin >> a >> b;
      string al;
      cin >> al;
      str.replace(a, b - a + 1, al);
    } else if(com == "reverse") {
      int a, b;
      cin >> a >> b;
      string temp = str.substr(a,b-a+1);
      for(int j = a; j <= b; j++) {
        temp[b-j] = str[j];
      }
      str.replace(a, b-a+1, temp);
    } else if(com == "print") {
      int a, b;
      cin >> a >> b;
      string ans;
      ans = str.substr(a,b-a+1);
      cout << ans << endl;
    }
   }
  return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
struct UF{
    int N;
    int par[100],sz[100];
    void init(int _N){
        N=_N;
        for(int i=0;i<N;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        par[y]=x;
        sz[x]+=sz[y];
        sz[y]=0;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};
typedef pair<int,int>pr;
typedef pair<int,pr>ppr;
int main(){
    int N;
    while(scanf("%d",&N),N){
        int M;
        scanf("%d",&M);
        vector<ppr>V;
        for(int i=0;i<M;i++){
            int a,b,c;
            scanf("%d,%d,%d",&a,&b,&c);
            c=c/100-1;
            V.push_back(ppr(c,pr(a,b)));
        }
        sort(V.begin(),V.end());

        UF uf;
        uf.init(N);
        int ret=0;
        for(int i=0;i<M;i++){
            int a=V[i].second.first;
            int b=V[i].second.second;
            int c=V[i].first;
            if(uf.same(a,b))continue;
            uf.unite(a,b);
            ret+=c;
        }
        printf("%d\n",ret);
    }
    return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < D; ++j)
        {
            cin >> X[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            int norm = 0;
            for (int k = 0; k < D; ++k)
            {
                int diff = abs(X[i][k] - X[j][k]);
                norm += diff * diff;
            }
            bool flag = false;
            for (int k = 0; k <= norm; ++k)
            {
                if (k * k == norm)
                {
                    flag = true;
                }
            }
            if (flag)
                ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x,y,s;
    while(scanf("%d %d %d",&x,&y,&s),x) {
        int ans=0;
        for(int i=1;i<s;i++) {
            for(int j=i;j<s;j++) {
                int sum=i*(100+x)/100+j*(100+x)/100;
                if(sum!=s) continue;
                ans=max(ans,i*(100+y)/100+j*(100+y)/100);
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3196
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: u64, k: u64,
    }
    let M = 1_000_000_007u64;

    let facts = fact_table(2 * n as usize, M);

    let mut ans = 0u64;
    for i in 0..=min(k, n-1) {
        let mut res = 1;
        res *= mod_comb(n, i, M, &facts);
        res *= mod_comb_repetition(n-i, i, M, &facts);
        res %= M;
        ans += res;
        ans %= M;
    }
    println!("{}", ans);

}

#[allow(dead_code)]
pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
#[allow(dead_code)]
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
#[allow(dead_code)]
/// (gcd, x, y)
pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (gcd, x, y) = extgcd(b, a % b);
        (gcd, y, x - (a / b) * y)
    }
}
#[allow(dead_code)]
/// x ^ n % m
pub fn mod_pow(x: u64, n: u64, m: u64) -> u64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
#[allow(dead_code)]
pub fn mod_inverse(a: u64, m: u64) -> u64 {
    let (_, x, _) = extgcd(a as i64, m as i64);
    ((m as i64 + x) as u64 % m) % m
}
#[allow(dead_code)]
pub fn fact_table(len: usize, m: u64) -> Vec<u64> {
    let mut res = vec![1; len + 1];
    for i in 1..len + 1 {
        res[i] = (i as u64 * res[i - 1]) % m;
    }
    res
}
#[allow(dead_code)]
/// Factorial and Inverse factorial table
pub fn fact_inv_table(size: usize, m: u64) -> (Vec<u64>, Vec<u64>) {
    let mut fact = vec![1; size];
    let mut fact_inv = vec![1; size];
    for i in 2..size {
        fact[i] = fact[i - 1] * i as u64 % m;
        fact_inv[i] = m - ((m / i as u64) * fact_inv[(m % i as u64) as usize] % m);
    }
    for i in 1..size {
        fact_inv[i] = fact_inv[i - 1] * fact_inv[i] % m;
    }
    (fact, fact_inv)
}
#[allow(dead_code)]
/// (a mod p, e when n! = a p\^e)
pub fn mod_fact(n: u64, p: u64, fact: &[u64]) -> (u64, u64) {
    if n == 0 {
        (1, 0)
    } else {
        let (a, b) = mod_fact(n / p, p, fact);
        let pow = b + n / p;
        if n / p % 2 != 0 {
            (a * (p - fact[(n % p) as usize]) % p, pow)
        } else {
            (a * fact[(n % p) as usize] % p, pow)
        }
    }
}
#[allow(dead_code)]
/// C(n, k) % p
pub fn mod_comb(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    if n < k {
        0
    } else {
        let (a1, e1) = mod_fact(n, p, fact);
        let (a2, e2) = mod_fact(k, p, fact);
        let (a3, e3) = mod_fact(n - k, p, fact);
        if e1 > e2 + e3 {
            0
        } else {
            a1 * mod_inverse(a2 * a3 % p, p) % p
        }
    }
}
#[allow(dead_code)]
/// H(n, k) % p
pub fn mod_comb_repetition(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    mod_comb(n - 1 + k, n - 1, p, fact)
}

Measured memory_bytes: 5188
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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

const int INF = 1e+9;

// pos を通る最短のループを返す
vector<int> bfs(int pos, vector<vector<int>>& G)
{
    int N = G.size();

    // pos からの最短距離を求める (最短経路もついでに出しておく)
    vector<int> dist(N, INF), prev(N, -1);
    dist[pos] = 0;
    queue<int> q;
    q.push(pos);
    while(!q.empty()){
        int tmp = q.front(); q.pop();
        for(int v: G[tmp]){
            if(dist[v] != INF) continue;
            dist[v] = dist[tmp]+1;
            prev[v] = tmp;
            q.push(v);
        }
    }

    // pos に直接繋がっている頂点のうち、最短距離のものを求める
    int d = 1e+9, idx = -1;
    REP(i, N){
        for(int v: G[i]){
            if(v == pos and dist[i] < d){
                d = dist[i];
                idx = i;
            }
        }
    }

    if(idx == -1) return vector<int>(N+1);
    else{
        // 経路復元
        vector<int> ret;
        while(idx != -1){
            ret.push_back(idx);
            idx = prev[idx];
        }
        return ret;
    }
}


int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    REP(i, M){
        int A, B;
        cin >> A >> B;
        --A, --B;
        G[A].push_back(B);
    }

    // 全ての頂点から始まるループのうち、最小のものの経路を求める
    vector<int> ans(N+1);
    REP(i, N){
        auto tmp = bfs(i, G);
        if(tmp.size() < ans.size()) ans = tmp;
    }

    int K = ans.size();
    if(K == N+1) cout << -1 << endl;
    else{
        cout << K << endl;
        for(int v: ans) cout << v+1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

int main(){
    int r;
    std::cin >> r;

    if(r < 1200){
        std::cout << "ABC" << std::endl;
    }else if(r < 2800){
        std::cout << "ARC" << std::endl;
    }else{
        std::cout << "AGC" << std::endl;
    }

    return 0;
}

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int a, b; cin >> a >> b;

  cout << (a-1) * (b-1) << endl;

  return (0);
}


Measured memory_bytes: 3644
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
string s;
int j;
int main()
{
	cin>>s;
    for(int i=0;i<s.size()-8;i++) cout<<s[i];
	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 repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc063_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  cin >> S;

  set<char> s;
  rep(i, S.size()) { s.insert(S[i]); }

  cout << (S.size() == s.size() ? "yes" : "no") << endl;
}

Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
// 0, 1,2
int r, s, p;
ll calcHand(ll opposite, ll you)
{
  if (opposite == 0 && you == 2)
  {
    return p;
  }
  if (opposite == 1 && you == 0)
  {
    return r;
  }
  if (opposite == 2 && you == 1)
  {
    return s;
  }
  return 0;
}
ll getHand(char h)
{
  if (h == "r"[0])
  {
    return 0;
  }
  if (h == "s"[0])
  {
    return 1;
  }
  if (h == "p"[0])
  {
    return 2;
  }
  return 0;
}

int main()
{
  ll n, k;
  string t;
  ll ans = 0;
  cin >> n >> k >> r >> s >> p >> t;
  map<int, vector<int>> modk;
  rep(i, n)
  {
    int c = getHand(t[i]);
    modk[i % k].push_back(c);
  }
  for (pair<int, vector<int>> p : modk)
  {
    ll modKMax;
    ll siz = p.second.size();
    vector<ll> dpR(siz + 1);
    vector<ll> dpS(siz + 1);
    vector<ll> dpP(siz + 1);
    dpR[0] = 0;
    dpS[0] = 0;
    dpP[0] = 0;
    rep(i, siz)
    {
      dpR[i + 1] = max(dpS[i] + calcHand(p.second[i], 0), dpP[i] + calcHand(p.second[i], 0));
      dpS[i + 1] = max(dpR[i] + calcHand(p.second[i], 1), dpP[i] + calcHand(p.second[i], 1));
      dpP[i + 1] = max(dpS[i] + calcHand(p.second[i], 2), dpR[i] + calcHand(p.second[i], 2));
    }
    modKMax = max(dpR[siz], dpS[siz]);
    modKMax = max(modKMax, dpP[siz]);
    ans += modKMax;
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 10048
#include <iostream>
#include <vector>
#include <math.h>


using namespace std;


#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS) //?????????????????????????????????

//??????????????????????????????
class Point{

public:

	double x, y;//??§?¨????????????????x,y??????

	Point(double x = 0,double y = 0):x(x),y(y){}

	Point operator + (Point p) {
		return Point(x + p.x, y + p.y);
	}

	Point operator - (Point p) {
		return Point(x - p.x, y - p.y);
	}

	Point operator * (Point p) {
		return Point(x * p.x, y * p.y);
	}

	Point operator / (Point p) {
		return Point(x / p.x, y / p.y);
	}

	double norm() {
		return x*x + y*y;
	}

	//?????????????????§???????????????
	double abs() {
		return sqrt(norm());
	}

	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS &&  fabs(y - p.y) < EPS;
	}

};

typedef Point Vector;

struct Segment {
	Point p1, p2;
};

typedef Segment Line;


typedef vector<Point> Polygon;

//??????????????????????????????
double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

//??????????????????????????????
double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

//?????????????????´?????????
bool isOrthogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}

//??????????§??????¨?????????????????´?????????
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
	return isOrthogonal(a1 - a2, b1 - b2);
}

//???????????´?????????
bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

//???????????????????????????
bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}

//??????????§??????¨???????????????????????????
bool isParallel(Point a1, Point a2, Point b1, Point b2) {
	return isParallel(a1 - a2, b1 - b2);
}

//?????????????????????
bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}





//???
class Circle {
public:
	Point c;//??????
	double r;//??????
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};






int main(void)
{
	int n;

	Point p[4];

	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> p[j].x >> p[j].y;
		}

		if (isOrthogonal(p[0], p[1], p[2], p[3])) {
			cout << 1 << endl;
		}
		else if (isParallel(p[0], p[1], p[2], p[3])) {
			cout << 2 << endl;
		}
		else {
			cout << 0 << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>

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

// 前方宣言.
struct Edge;

// グラフ頂点
struct Node {
    int color;
    vector<Edge> edges;
};

// グラフ辺
struct Edge {
    Node* connected_node;
    bool is_odd;
    Edge(Node* node_, bool is_odd_) {
        connected_node = node_;
        is_odd = is_odd_;
    }
};

void dfs_setColor(Node* node_, Node* root_node) {
    for (Edge edge_ : node_->edges) {
        // 双方向グラフにしてあるので、戻りのEdgeは無視する.
        if (edge_.connected_node == root_node) {
            continue;
        }
        edge_.connected_node->color = (edge_.is_odd) ? node_->color ^ 0b1 : node_->color;
        dfs_setColor(edge_.connected_node, node_);
    }
}

int main() {

    int n;
    cin >> n;

    Node nodes[n + 1] = {};

    // 木構築
    rep(i, n - 1) {
        int node_from, node_to;
        ll node_size;
        cin >> node_from >> node_to >> node_size;

        // Edge設定
        nodes[node_from].edges.push_back(Edge(&nodes[node_to], node_size % 2));
        nodes[node_to].edges.push_back(Edge(&nodes[node_from], node_size % 2));
    }

    // node1から巡回する
    dfs_setColor(&nodes[1], NULL);

    // 結果表示
    for(int i = 1; i< n+1 ; i++) {
        cout << nodes[i].color << endl;
    }

    return 0;
}


Measured memory_bytes: 9984
#include <cstdio>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 9999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

const int M = 20;
Weight best[1<<M][M];
int    prev[1<<M][M];
void buildPath(int S, int i, vector<int> &path) {
  if (!S) return;
  buildPath(S^(1<<i), prev[S][i], path);
  path.push_back(i);
}
Weight shortestHamiltonCycle(Matrix w, vector<int> &path) {
  int n=w.size();
  int N = 1 << n;
  REP(S,N) REP(i,n) best[S][i] = INF;
  best[0][0] = 0;
  REP(S,N) REP(j,n) REP(i,n) if (!(S&(1<<j)))
    if (best[S|(1<<j)][j] > best[S][i] + w[i][j])
      best[S|(1<<j)][j] = best[S][i] + w[i][j],
      prev[S|(1<<j)][j] = i;
  //int t = min_element(best[N-1], best[N-1]+n) - best[N-1];
  //path.clear(); buildPath(N-1, t, path);
  return best[N-1][0]==INF ? -1 : best[N-1][0];
}

int main(){
	int V,E,s,t,d;
	scanf("%d%d",&V,&E);
	Matrix m(V,Array(V));
	for(s=0;s<V;s++)for(t=0;t<V;t++)if(s!=t)m[s][t]=INF;
	vector<int>path;
	for(;E--;)scanf("%d%d%d",&s,&t,&d),m[s][t]=d;
	printf("%d\n",shortestHamiltonCycle(m,path));
}

Measured memory_bytes: 9240
n =int(input())
s_list = list(input() for i in range(1,n+1))

from collections import Counter

c = Counter(s_list)
max = max(list(c.values()))

list = []
for kv in c.items():
    if kv[1]== max:
        list.append(kv[0])


list.sort()
list_new = '\n'.join(list)

print(list_new)
        

        




Measured memory_bytes: 35984
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());
// Segment Tree for query min[a, b)
class RangeMinimumQuery {
    int N;
    vector<long long> dat;

public: RangeMinimumQuery(int n) {
      N = 1;
      while(N < n) N *= 2;
      dat.resize(2*N-1, LLONG_MAX);
    }

    // update k-th element
public: void update(int k, long long a) {
      k += N-1;
      dat[k] = a;
      while(k > 0) {
        k = (k-1)/2;
        dat[k] = min(dat[k*2+1], dat[k*2+2]);
      }
    }

    // add k-th element by a
public: void add(int k, long long a) {
      k += N-1;
      dat[k] += a;
      while(k > 0) {
        k = (k-1)/2;
        dat[k] = min(dat[k*2+1], dat[k*2+2]);
      }
    }

    // return k-th element
public: long long get(int k) {
      return dat[k+N-1];
    }

    // return min[a, b)
public: long long query(int a, int b) {
      return query(a, b, 0, 0, N);
    }

    long long query(int a, int b, int k, int l, int r) {
      if (r <= a || b <= l) return LLONG_MAX;
      if (a <= l && r <= b) return dat[k];
      int m = (l+r)/2;
      return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};


class DShortestPathOnALine {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      vector<pair<P, int>> vec(m);
      rep(i, m) {
        cin >> vec[i].first.first >> vec[i].first.second >> vec[i].second;
      }
      sort(all(vec));
      RangeMinimumQuery rmq(n+1);
      rmq.update(1, 0);
      rep(i, m) {
        auto st = rmq.query(vec[i].first.first, n+1);
        if (st == LLONG_MAX) continue;
        if (st+vec[i].second < rmq.get(vec[i].first.second)) {
          rmq.update(vec[i].first.second, st+vec[i].second);
        }
      }

      if (rmq.get(n) == LLONG_MAX) {
        cout << -1 << endl;
      } else {
        cout << rmq.get(n) << endl;
      }
    }
};

signed main() {
  DShortestPathOnALine solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int c[3][3];

int main() {
    rep(i, 3)rep(j, 3) cin >> c[i][j];

    // 総当たりで間に合う 3 x 3 x 100
    // 半分調べれば充分そう

    for (int i = 0; i <= 100; i++) {
        int a[3], b[3];
        a[0] = i;
        b[0] = c[0][0] - i;
        b[1] = c[0][1] - i;
        b[2] = c[0][2] - i;

        a[1] = c[1][1] - b[1]; 
        a[2] = c[2][1] - b[1];

        if (b[0] < 0 || b[1] < 0 || b[2] < 0 || a[1] < 0 || a[2] < 0) {
            continue;
        }

        if (b[0] > 100 || b[1] > 100 || b[2] > 100 || a[1] > 100 || a[2] > 100) {
            continue;
        }

        // cout << c[2][1] << endl;
        // cout << b[1] << endl;
        // judge
        bool ans = true;
        rep(m, 3) {
            rep(n, 3) {
                // printf("m %d n %d a[m] + b[n] %d\n", a[m], b[n], a[m] + b[n]);
                // cout << a[m] + b[n] << endl;
                if (c[m][n] != (a[m] + b[n])) {
                    ans = false;
                }
            }
        }
        if (ans) {
            // printf("a1 %d a2: %d a3: %d b1: %d b2: %d b3: %d\n", a[0], a[1], a[2], b[0], b[1], b[2]);
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>

using namespace std;

int main()
{
  int n,m ;
  cin >> n >> m ;
  
  int a[n][m];
  int b[m];
  
  int ans[n] ;
  int ans2[n] ;

  for(int j=0;j<n;j++){
       ans[j] = 0 ;
     }
  
  for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          cin >> a[i][j] ;
      }
  }
  for(int j=0;j<m;j++){
       cin >> b[j] ;
     }
     
  for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          ans[i] += a[i][j]*b[j]  ;
      }
  }
     
  for(int j=0;j<n;j++){
       cout << ans[j] << "\n" ;
     }
 

  
    return 0;
}




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

signed main() {
  ios::sync_with_stdio( 0 );
  set< tuple< int, int, int > > bag;
  int t[ 3 ];
  for( int i = 0; i < 3; ++i ) {
    cin >> t[ i ];
  }
  sort( t, t + 3 );
  int ans = 0;
  for( ; ; ) {
    if( bag.count( make_tuple( t[ 0 ], t[ 1 ], t[ 2 ] ) ) ) {
      cout << -1 << endl;
      exit( 0 );
    }
    if( t[ 0 ] % 2 or t[ 1 ] % 2 or t[ 2 ] % 2 ) break;
    ++ans;
    bag.emplace( t[ 0 ], t[ 1 ], t[ 2 ] );
    int a = t[ 1 ] / 2 + t[ 2 ] / 2;
    int b = t[ 0 ] / 2 + t[ 2 ] / 2;
    int c = t[ 0 ] / 2 + t[ 1 ] / 2;
    t[ 0 ] = a;
    t[ 1 ] = b;
    t[ 2 ] = c;
    sort( t, t + 3 );
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

const int dx[4] = {-1 ,0 ,1 ,0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    int H, W; cin >> H >> W;
    vector<vector<char>> grid(H+2, vector<char>(W+2, '.'));
    rep(i, H){
        string s; cin >> s;
        rep(j, W){
           grid[i+1][j+1] = s[j];
        }
    }
    
    bool fg = true;
    rep(i, H){
        rep(j, W){
            if(grid[i+1][j+1] == '.') continue;
            bool is_allWhite = true;
            rep(k, 4){
                int x = j+1 + dx[k];
                int y = i+1 + dy[k];
                if(grid[y][x] == '#'){
                    is_allWhite = false;
                    break;
                }
            }
            if(is_allWhite){ fg = false; break;}
        }
    }

    if(fg) cout << "Yes" << ln;
    else cout << "No" << ln;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int t[2][2010][2010],n,k;
int F(int a,int b,int c,int d,int r){
  a++,b++,c++,d++;
  int cnt=t[r][c][d];
  cnt-=t[r][c][b-1];
  cnt-=t[r][a-1][d];
  cnt+=t[r][a-1][b-1];
  return cnt;
}
int main(){
  cin>>n>>k;k*=2;
  lol(i,k+1)lol(j,k+1)t[0][i][j]=0,t[1][i][j]=0;
  lol(i,n){
    int a,b;char z;
    cin>>a>>b>>z;
    if(z=='W')t[0][a%k+1][b%k+1]++;
    if(z=='B')t[1][a%k+1][b%k+1]++;
  }
  lol(i,k+1){
    lol(j,k+1){
      if(i==0||j==0)continue;
      lol(r,2){
	t[r][i][j]+=t[r][i-1][j];
	t[r][i][j]+=t[r][i][j-1];
	t[r][i][j]-=t[r][i-1][j-1];
      }
    }
  }
  int ans=0;
  lol(i,k/2)lol(j,k/2){
    lol(r,2){
      int cnt,x=j+k/2,y=i+k/2,e=k-1;
      
      cnt=F(0,0,i,j,r);
      cnt+=F(i+1,j+1,y,x,r);
      cnt+=F(y+1,0,e,j,r);
      cnt+=F(0,x+1,i,e,r);
      cnt+=F(y+1,x+1,e,e,r);
      
      cnt+=F(0,j+1,i,x,1-r);
      cnt+=F(i+1,0,y,j,1-r);
      cnt+=F(y+1,j+1,e,x,1-r);
      cnt+=F(i+1,x+1,y,e,1-r);
      
      ans=max(ans,cnt);
      //cout<<i<<" "<<j<<" "<<r<<" "<<cnt<<endl;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 31744
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  while (true) {
    long long n, m;
    cin >> n >> m;
    if (n == 0)
      break;
    vector<pair<long long, long long>> dps(n);
    for (int i = 0; i < n; i++)
      cin >> dps[i].first >> dps[i].second;

    sort(dps.begin(), dps.end(),
         [](const pair<long long, long long> &lhs,
            const pair<long long, long long> &rhs) {
           return lhs.second > rhs.second;
         });
    long long save = 0;
    for (int i = 0; i < n; i++) {
      if (m > dps[i].first) {
        save += dps[i].second * dps[i].first;
        m -= dps[i].first;
      } else {
        save += dps[i].second * m;
        m = 0;
        break;
      }
    }
    long long sum = 0;
    for (int i = 0; i < n; i++)
      sum += dps[i].first * (dps[i].second);
    cout << sum - save << endl;
  }

  return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,d,i,j,k,dp[1000005][2],g[1000005],fac[1000005],inv[1000005],fi[1000005],mod=1e9+7;
int main()
{
	fac[1]=fac[0]=inv[1]=fi[0]=fi[1]=1;
	fz(i,2,1000003){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}
	scanf("%lld%lld%lld",&n,&m,&d);
	long long syx=1;fz(i,2,n)(syx+=fac[i])%=mod;
	fz1(i,min(d,m)) dp[i][1]=fac[n];
	fz1(i,m){
		(g[i]+=g[i-1])%=mod;
		(dp[i][1]+=g[i])%=mod;
		(g[i+1]+=dp[i][1]*syx)%=mod;
		(g[min(i+d,m)+1]+=(mod-dp[i][1])*syx)%=mod;
	}
	cout<<dp[m][1]*fac[n]%mod*fi[n]%mod<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    int count=0;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;)
    {
        int j=i+1;
        count++;
        while(a[i]==a[j])
        {
            j++;
        }
        if((j-i)%2==0)
            count--;
        i=j;
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int m, d;
    cin >> m >> d;

    int ans = 0;
    for(int i=1; i<=m; i++){
        for(int j=1; j<=d; j++){
            int x = j%10, y = j/10;
            if(x>1 && y>1 && x*y == i){
                ans++;
            }
        }
    }

    cout << ans << endl;
}

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


namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			if (arr[0] % arr[1] == 0)
			{
				Console.WriteLine(arr[0] / arr[1]);
			}
			else
			{
				Console.WriteLine(arr[0] / arr[1] + 1);
			}


		}

	}

}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll dp[100][100001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,W;
    cin>>N>>W;
    ll w[N],v[N];
    rep(i,0,N) cin>>w[i]>>v[i];
    rep(i,0,N){
        rep(j,0,W+1){
            if(i==0){
                dp[i][j]=(j>=w[i]?v[i]:0);
            }
            else{
                dp[i][j]=max(dp[i-1][j],(j>=w[i]?dp[i-1][j-w[i]]+v[i]:0));
            }
        }
    }
    cout <<dp[N-1][W]<<"\n";
}

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

ll dp[100010][2];
const ll MOD=1e9+7;

int main(){
    string s;
    cin>>s;
    ll n=s.size();
    dp[0][0]=1;
    rep(i,0,n){
        if(s[i]=='0'){
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=3*dp[i][1];
            dp[i+1][0]%=MOD;
            dp[i+1][1]%=MOD;
        }
        else{
            dp[i+1][0]=dp[i][0]*2;
            dp[i+1][1]=3*dp[i][1];
            dp[i+1][1]+=dp[i][0];
            dp[i+1][0]%=MOD;
            dp[i+1][1]%=MOD;
        }
    }
    ll an=dp[n][0]+dp[n][1];
    an%=MOD;
    cout<<an<<endl;
}

    









Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <set>
#include <iomanip>
typedef  long long ll;
using namespace std;

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

	ll ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			ans *= k;
		}
		else
		{
			ans *= (k - 1);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;


int main()
{

	map<char, bool> m;

	string S;
	cin >> S;

	for (int i = 0; i < 26; ++i)
	{
		m[(char)('a' + i)] = false;
	}

	for (int i = 0; i < S.length(); ++i)
	{
		m[S[i]] = true;
	}

	for (int i = 0; i < 26; ++i)
	{
		if (!m[(char)('a' + i)])
		{
			cout << (char)('a' + i) << endl;
			return 0;
		}
	}

	cout << "None" << endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
ll mod=1e9+7;
ll inv(ll a){
    ll n=mod-2,ans=1;
    while(n>0){
        if(n%2) ans=ans*a%mod;
        n=n/2;
        a=a*a%mod;
    }
    return ans;
}
ll A[2000001];
ll nCr(ll n,ll r){
    return A[n]*inv(A[r])%mod*inv(A[n-r])%mod;
}
int main(){
    ll x,y;
    cin>>x>>y;
    if((x+y)%3){cout<<0;return 0;}
    ll k=(2*y-x)/3,l=(2*x-y)/3;
    if(k<0||l<0){cout<<0;return 0;}
    A[0]=1;
    rep(i,2000000) A[i+1]=A[i]*(i+1)%mod;
    cout<<nCr(k+l,l);
}

Measured memory_bytes: 15872
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long long i = p; i < q; i++)
#define repd(i, p, q) for (long long i = p; i >= q; i--)
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> M;
typedef map<long, long> ML;
typedef map<long long, long long> MLL;
typedef pair<int, int> P;
typedef pair<long, long> PL;
typedef pair<long long, long long> PLL;
typedef int I;
typedef double D;
typedef long double LD;
typedef long L;
typedef long long LL;

int main()
{
    char a;
    cin >> a;
    if (a == 'A')
    {
        cout << "T";
    }
    else if (a == 'T')
    {
        cout << "A";
    }
    else if (a == 'C')
    {
        cout << "G";
    }
    else
    {
        cout << "C";
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long> a(n), ar(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ar[i + 1] = ar[i] + a[i];
  }
  vector<vector<long>> dp(n, vector<long>(n, 0));
  for (int i = 0; i < n; i++) dp[i][i] = 0;
  for (int d = 1; d < n; d++) {
    // d=r-l;
    for (int l = 0; l < n - d; l++) {
      int r = l + d;
      long m = 1000000000000000L;
      for (int i = l; i < r; i++) {
        m = min(m, dp[l][i] + dp[i + 1][r]);
      }
      dp[l][r] = m + ar[r + 1] - ar[l];
    }
  }
  cout << dp[0][n - 1];
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    unordered_set<ll> us;
    unordered_map<ll, ll> um;
    rep(i, n) {
        cin >> a[i];
        us.insert(a[i]);
        um[a[i]]++;
    }
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, n) {
        int upper = sqrt(a[i]);
        bool flag = true;
        for(int j = 1; j <= upper; j++) {
            if(a[i]%j == 0) {
                if(j == a[i]/j && um[1] == 1)
                    break;
                if(us.find(j) != us.end()) {
                    flag = false;
                    break;
                }
                if(us.find(a[i]/j) != us.end()) {
                    if(j != 1 && um[a[i]/j] == 1) {
                        flag = false;
                        break;
                    }
                    if(um[a[i]/j] > 1) {
                    flag = false;
                    break;

                    }
                }
            }
        }
        if(flag)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 21360
n,k = map(int,input().split())
a = list(map(int,input().split()))
min = 0
x = a.index(1) +1
if n==k:
  print(1)
elif (n-k)%(k-1)==0:
  print(1 + (n-k)//(k-1))
else:
  print(2 + (n-k)//(k-1))

Measured memory_bytes: 52652
N = int(input())
a = list(map(int,(input().split())))
c = 0
for i in range(N-1):
    if a[i] == i+1:
        tmp = a[i+1]
        a[i+1] = a[i]
        a[i] = tmp
        c += 1
if a[N-1] == N:
    c += 1
print(c)

Measured memory_bytes: 52908
#include <stdio.h>
 
int main() {
  long long N, M;
  
  scanf("%ld %ld", &N, &M);
  if(N == 1 && M == 1) printf("1\n");
  else if(N == 1) printf("%ld\n", M - 2);
  else if(M == 1) printf("%ld\n", N - 2);
  else printf("%ld\n", (M - 2) * (N - 2));
  
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,q,d[maxn],nxt[maxn],ans[maxn],pre[maxn];
struct node{int s,t,x;}p[maxn];
struct node2{int x,id;};
set <int> s,tmp;
set <int>::iterator it1,it2;
map <int,int> mp;
vector <int> vec;

inline bool cmp(node a,node b){return a.x<b.x;}

int main()
{
	n=read(); q=read();
	for(int i=1;i<=n;i++) p[i].s=read(),p[i].t=read()-1,p[i].x=read();
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=q;i++) d[i]=read(),ans[i]=-1,s.insert(d[i]),mp[d[i]]=i;
	sort(d+1,d+q+1);
	for(int i=1;i<=n;i++)
	{
		vec.clear();
		it1=s.lower_bound(max(0,p[i].s-p[i].x));
		it2=s.upper_bound(max(0,p[i].t-p[i].x));
		
		for(set <int>::iterator it=it1;it!=it2;it++)
		{
			ans[mp[*it]]=p[i].x;
			vec.push_back(*it);
		}
		for(int i=0;i<vec.size();i++) s.erase(vec[i]);
	}
	for(int i=1;i<=q;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 25592
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[101010];
int C[101010];
int ma;

int dfs(int cur,int pre) {
	vector<int> V={0,0};
	FORR(e,E[cur]) if(e!=pre) V.push_back(dfs(e,cur));
	
	sort(ALL(V));
	reverse(ALL(V));
	ma=max(ma, C[cur]+V[0]+V[1]);
	C[cur]+=V[0];
	return C[cur];
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	int leaf=0;
	int st=-1;
	FOR(i,N) {
		if(E[i].size()==1) leaf++;
		if(E[i].size()==2) {
			C[i]=1;
			st=i;
		}
	}
	
	if(st==-1) return _P("%d\n",leaf);
	dfs(st,-1);
	_P("%d\n",leaf+ma);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
	int x = 0, fh = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') fh = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * fh;
}
const int N = 1e5 + 10;
int n, m, x, y, z, kx, ky, ans, i, f[N];
int find_root(int x) {
	if (x == f[x]) return x;
	return f[x] = find_root(f[x]);
}
int main() {
	n = read(); m = read();
	for (i = 1; i <= n; i++) f[i] = i;
	for (i = 1; i <= m; i++) {
		cin >> x >> y >> z;
		kx = find_root(x);
		ky = find_root(y);
		if (kx != ky) f[kx] = ky;
	}
	for (i = 1; i <= n; i++) if (f[i] == i) ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n,m;
    cin>>n>>m;
    ll x;
    cin>>x;
    ll ans=INF;
    vll c(n);
    ll a[n][m];
    rep(i,0,n){
        cin>>c[i];
        rep(j,0,m)cin>>a[i][j];
    }
    rep(i,0,1<<n){
        ll res=0;
        vll rikai(m,0);
        rep(j,0,n){
            if((i>>j)&1){
                res+=c[j];
                rep(k,0,m)rikai[k]+=a[j][k];
            }
        }
        bool check=true;
        rep(l,0,m){
            if(rikai[l]<x)check=false;
        }
        if(check)chmin(ans,res);
    }
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
class unionfind {
    vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う
public:
    unionfind(int n) :par(n), rank(n), size_(n, 1) {
        iota(all(par), 0);
    }
    int find(int x) {
        if (par[x] == x)return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])swap(x, y);
        par[y] = x;
        size_[x] += size_[y];
        if (rank[x] == rank[y])rank[x]++;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return size_[find(x)];
    }
};

signed main(){
    int N,K,L;
    cin >> N >> K >> L;
    auto t = unionfind(N);
    auto c = unionfind(N);
    for(int i = 0; i < K; ++i){
        int a,b; cin >> a >> b;
        --a,--b;
        t.unite(a,b);
    }
    for(int j = 0; j < L; ++j){
        int a,b; cin >> a >> b;
        --a,--b;
        c.unite(a,b);
    }
    map<pair<int,int>,int>cnt;
    for(int i = 0; i < N; ++i){
        cnt[make_pair(t.find(i), c.find(i))] += 1;
    }
    for(int i = 0; i < N; ++i)
        cout << cnt[make_pair(t.find(i),c.find(i))]<< endl;
}


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

const int M=10010;
const int N=110;

int n,s[N];
bool f[M];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	f[0]=true;
	for(int i=1;i<=n;i++)
		for(int j=M-1;j>=s[i];j--)
			f[j]|=f[j-s[i]];
	for(int j=M-1;j;j--)
		if(j%10&&f[j])
		{
			cout<<j;
			return 0;
		}
	cout<<0;
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
# L,Rで大きい方に傾く

N, A, B = map(int, input().split())
arr = []

for i in range(1, N+1):
  i_sum = sum(map(int, str(i)))
  if A <= i_sum and B >= i_sum:
    arr.append(i)
  else:
    continue

print(sum(arr))

Measured memory_bytes: 3296
#include <bits/stdc++.h> 
using namespace std; 
int main() 
    { 
    long long a; 
    double b; 
    cin >> a >> b; 
    long long r = a * (long long)round(b * 100.0) / 100; 
    cout << r << "\n"; 
    return 0; 
} 


Measured memory_bytes: 3756