akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

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

//#define int long long

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

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

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VL A(N); REP(i,N) cin >> A[i];
    if(A[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    int now = N-1;
    LL ans = 0;
    while(1){
        int pre = A[now];
        ans += pre;
        dump(now)
        for(int i = now-1; i >= 0; i--){
            if(A[i] == pre-1){
                pre = A[i];
                now = i;
            }else if(A[i] < pre-1){
                cout << -1 << endl;
                return 0;
            }else{
                now = i;
                break;
            }
        }
        if(now == 0){
            break;
        }

    }
    cout << ans << endl;

}


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

int main(void) {
   string S;
   cin >> S;
   int cnt = 0;
   int S_len = S.length();
   for (int i = 0; i < S_len; i++) {
      if (S[i] == '0') {
         cnt++;
      }
   }
   int ans = S_len - (cnt < S_len - cnt ? S_len - 2*cnt : cnt*2 - S_len);
   cout << ans << endl;
   return 0;
}


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

int N, M;
struct edge {
  ll from, to, cost;
};
static const ll INF = 1000000000000;
edge es[2000];
ll d[1000];

bool find_negative_loop(int s){
    int cnt = 0;
    for(int i = 0; i < N; i++){
        d[i] = INF;
    }
    
    d[s] = 0;
    for(int cnt = 0; cnt < N; cnt++) {
        bool update = false;
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update){
            return false;
        }
    }
    
    for(int i = 0; i < M; i++){
        edge e = es[i];
        if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
            d[e.to] = d[e.from] + e.cost;
            if(e.to == N - 1){
                return true;
            }
        }
    }
    
    return false;
}

int main(void){
    // Your code here!
    cin >> N >> M;
    ll a, b, c;
    for(int i = 0; i < M; i++){
        cin >> a >> b >> c;
        es[i].from = a - 1;
        es[i].to = b - 1;
        es[i].cost  = -c;
    }
    
    if(find_negative_loop(0)){
        cout << "inf" << endl;
    } else {
        cout << -d[N-1] << endl;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int a=0,b=0;
	int s[100002]={0};
	int k[100000];
	int n,x;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		s[x]++;
	}
	for(int i=0;i<100002;i++){
		if(s[i]){
			b++;
			if(s[i]%2==0){
			k[a++]=i;
			}
		}
	}
	if(a==2||a%2==1) cout<<b-1<<endl;
	else cout<<b<<endl;


return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
int main() {
    int x;
    cin >> x;
    if(400 <= x && x <= 599){
        cout << 8 << endl;
        return 0;
    }else if(600 <= x && x <= 799){
        cout << 7 << endl;
        return 0;
    }else if(800 <= x && x <= 999){
        cout << 6 << endl;
        return 0;
    }else if(1000 <= x && x <= 1199){
        cout << 5 << endl;
        return 0;
    }else if(1200 <= x && x <= 1399){
        cout << 4 << endl;
        return 0;
    }else if(1400 <= x && x <= 1599){
        cout << 3 << endl;
        return 0;
    }else if(1600 <= x && x <= 1799){
        cout << 2 << endl;
        return 0;
    }else if(1800 <= x && x <= 1999){
        cout << 1 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
void solve(){
	ll n,i,j;
	cin>>n;
	ll p=n%1000;
	if(p==0){
		cout<<0<<endl;
	}else
		cout<<1000-p<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int main() {
	int n;
	int a[100000];
	int f = 0, t = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] % 4 == 0) {
			f += 1;
		}
		else if (a[i] % 2 == 0) {
			t += 1;
		}
	}
	n = n - f - t;
	if (n <= f + 1 && t == 0) {
		cout << "Yes" << endl;
	}
	else if (n <= f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
int partition(std::vector<int>&A, int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p; j <= r - 1; ++j) {
		if (A[j] <= x) {
			++i;
			std::swap(A[i], A[j]);
		}
	}
	std::swap(A[i + 1], A[r]);
	return i + 1;
}
int main(void) {
	std::ios_base::sync_with_stdio(false);
	int n;
	std::cin >> n;
	std::vector<int>Input(n, 0);
	for (int i = 0; i < n; ++i) {
		std::cin >> Input[i];
	}
	int criterion = partition(Input, 0, n-1 );
	for (int i = 0; i < n; ++i) {
		if (i != criterion) std::cout << Input[i];
		else std::cout << "[" << Input[i] << "]";
		if (i == n - 1) std::cout << std::endl;
		else std::cout << " ";
	}
//	system("pause");
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int n, a;
  cin >> n >> a;
  n %= 500;
  if (n <= a) cout << "Yes";
  else cout << "No";
    return 0;
}

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

int main(){
    long long A,B,n;
    cin >> A >> B >> n;
    int a = A/B, b = A%B;
    if(n >= B-1){
        cout << a*(B-1)+((b*(B-1))/B) << endl;
    }
    else cout << a*n+((b*n)/B) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int k; cin >> k;
    k--;
    rep(i,n) {
        if (s[i] != s[k]) s[i] = '*';
    }
    cout << s << endl;
}


Measured memory_bytes: 3620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
    }

    println!("{}", 6 - a - b);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n;
    cin>>n;
    vector<long int> v(n);
    for(long int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int totalcost[n+1]={0};
    totalcost[0]=0;
    totalcost[1]=0;
    totalcost[2]=abs(v[0]-v[1]);
    for(int i=3;i<n+1;i++)
    {
        totalcost[i]=min(totalcost[i-1]+abs(v[i-1]-v[i-2]),totalcost[i-2]+abs(v[i-1]-v[i-3]));
    }
    cout<<totalcost[n]<<endl;
    return 0;
}


Measured memory_bytes: 1408
//c.......

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int b[200001];
int next[200001];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int a,aa;
    for (int i=0;i<m; i++) {
        scanf("%d%d",&a,&aa);
        if(aa==n) next[a]=aa;
        if(a==1) b[aa]++;
    }
    int i = 0;
    int flag = 0;
    for(i=1;i<200001;i++){
        if(b[i]){
            if(next[i] == n) {
                flag = 1;
                break;
            }
        }
    }
    if(flag==1) printf("POSSIBLE");
    //else if(i==200000)printf("IMPOSSIBLE");
    else printf("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<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,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    string s,t;
    cin>>s>>t;
    vi kindts(26,-1);
    vi kindst(26,-1);
    rep(i,t.size()){
        if(kindst[s[i]-'a']==-1&&kindts[t[i]-'a']==-1){
            kindst[s[i]-'a']=t[i];
            kindts[t[i]-'a']=s[i];
        }
        else if(kindts[t[i]-'a']==s[i]&&kindst[s[i]-'a']==t[i]){
            continue;
        }
        else {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}




Measured memory_bytes: 776
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LIN(N)
    ans = 0
    for i in range(N-1):
        ans += A[i]//2
        A[i]&=1
        use = min(A[i],A[i+1])
        ans += use 
        A[i+1]-= use 
        A[i]-= use 
    ans += A[-1] // 2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 70360
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    map<int, int> mp;
    for (int i = 1; i < N; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    REP(i, N) {
        cout << mp[i + 1] << endl;
    }
}

Measured memory_bytes: 12984
#include <bits/stdc++.h>
#define ll long long
#define db double
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2e5+10,M=3e4+10;
const ll inf=INT_MAX,mod=1e9+7;
const db pi=atan(1)*4;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a)%mod; a=(a*a)%mod; b/=2; } return s;}
ll lcm(ll a,ll b) {return a/__gcd(a,b)*b; }
int read()
{
    int s=0,f=1; char ch=getchar();
    while(ch<'0'&&ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {s=s*10+ch-'0'; ch=getchar();} return s*f;
}

int n,a[105],ans=0;

int main()
{
    iosks;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&abs(a[i]-a[j])<a[k]&&abs(a[j]-a[k])<a[i]&&abs(a[i]-a[k])<a[j]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]) ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%d",min(a,b)+min(c,d));
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
f = []
for i in range(n):
    tmp = 0
    for j in map(int, input().split()):
        tmp <<= 1
        tmp |= j
    f.append(tmp)
pay = [list(map(int, input().split())) for _ in range(n)]
ans = -float('INF')
for i in range(1,1<<10):
    tmp = 0
    for j in range(n):
        tmp += pay[j][str(bin(f[j] & i)).count('1')]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    a=toupper(a[0]);
    b=toupper(b[0]);
    c=toupper(c[0]);
    cout<<a<<b<<c<<endl;
    return 0;
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#define PRE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
const int Mod = 1e9 + 7;
int lst[Max][2], f[Max];
int ls[Max];

void init(int n)
{
	for (int i = 1;i <= n;i++) f[i] = i;
}

int getf(int a)
{
	if (a != f[a])return f[a]=getf(f[a]);
	return a;
}

void merge(int a, int b)
{
	f[a] = getf(a);
	f[b] = getf(b);
	if (f[b] != f[a]) f[f[b]] = f[a];
}

int main()
{
	PRE;
	int n, m;
	cin >> n >> m;
	for (int i = 1;i <= m;i++)
	{
		cin >> lst[i][0] >> lst[i][1];
	}
	int res = 0;
	for (int i = 1;i <= m;i++)
	{
		init(n);
		for (int j = 1;j <= m;j++)
		{
			if (i == j)continue;
			merge(lst[j][0], lst[j][1]);
		}
		int sum = 0;
		for (int k = 1;k <= n;k++)
		{
			getf(k);
			if (f[k] == k)sum++;
		}
		if (sum >= 2)res++;
	}
	cout << res;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,x;
	cin>>x;
	for(int i=-155;i<155;i++){
		for(int j=-155;j<155;j++){
			if((pow(i,5)-pow(j,5))==x){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007;
int main()
{
    ll n;
    cin>>n;
    double p[n+1],dp[n+1][n+1],ans=0;
    
    for(int i=1;i<=n;i++)
        cin>>p[i];
    
    dp[0][0]=1;
    
    for(int i=1;i<=n;i++)
        dp[0][i]=0.0;
    for(int i=1;i<=n;i++)
        dp[i][0]=dp[i-1][0]*(1.0-p[i]);
        
        
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
             dp[i][j]=(dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i])*1.0;
             
             
    for(int i=(n+1)/2;i<=n;i++)
        ans=ans+dp[n][i];
    cout<<setprecision(9)<<ans<<endl;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    unordered_map<ll,ll> mp;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]+i]++;
        ans += mp[i-a[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 19996
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;


int main(void) {
	int a, b; cin >> a >> b;
	rep(i, 10005) {
		if (int(i*0.08) == a && int(i*0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=110000;
ll x[N], s[N], t[N], buf[N];

int main() {
    ll i, j, k, l, m, n, q;
    scanf("%lld", &n);
    for(i=1; i<=n; i++) scanf("%lld", &x[i]);
    scanf("%lld%lld", &m, &k);
    for(i=1; i<=n; i++) s[i]=i;
    while(m--) {
        scanf("%lld", &i);
        swap(s[i], s[i-1]);
    }
    for(i=1; i<=n; i++) {
        t[s[i]]=i;
        s[i]=0;
    }
    for(i=1; i<=n; i++) if(!s[i]) {
        j=i, q=0;
        do {
           buf[q++]=j;
           j=t[j];
        } while(i!=j);
        j=i, l=k%q;
        do {
            s[j]=buf[l];
            l=(l+1)%q;
            j=t[j];
        } while(j!=i);
    }
    for(i=0; i<=n; i++) buf[i]=0;
    for(i=1; i<=n; i++) {
        buf[s[i-1]+1]+=x[i];
        buf[s[i]+1]-=x[i];
    }
    for(i=1; i<=n; i++) {
        buf[i]+=buf[i-1];
        printf("%lld\n", buf[i]);
    }
    return 0;
}

Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	s := []int{a, b}
	if !contain(s, 1) {
		fmt.Println(1)
	}
	if !contain(s, 2) {
		fmt.Println(2)
	}
	if !contain(s, 3) {
		fmt.Println(3)
	}
}

func contain(s []int, i int) bool {
	for _, v := range s {
		if i == v {
			return true
		}
	}
	return false
}

Measured memory_bytes: 512
def main():
    K = int(input())

    tmp1 = 7 % K
    tmp2 = tmp1

    for i in range(1, 10**6):
        if tmp2 == 0:
            print(i)
            exit()
        else:
            tmp1 = tmp1 * 10 % K
            tmp2 += tmp1
            tmp2 %= K

    print(-1)


if __name__ == "__main__":
    main()


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for(int l = 0, r = N - 1; l < r;) {
        while(l < r && S[l] == 'R') l++;
        while(l < r && S[r] == 'W') r--;
        if(l >= r) break;
        ans++;
        l++;
        r--;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3748
n = int(input())
a = []
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xx, yy = (int(i) for i in input().split())
        x[i].append(xx)
        y[i].append(yy)

testimony = [[2]*n for i in range(n)]

for i in range(n):
    for j in range(a[i]):
        if(y[i][j] == 1):
            testimony[i][x[i][j]-1] = 1
        elif(y[i][j] == 0):
            testimony[i][x[i][j]-1] = 0

ans = 0
for i in range(2**n):
    bit_list = []
    for j in range(n):
        if ((i >> j) & 1):
            bit_list.append(1)
        else:
            bit_list.append(0)
    flag = 1
    for k in range(n):
        if(bit_list[k] == 1):
            for l in range(n):
                if(testimony[k][l] != 2):
                    if(testimony[k][l] != bit_list[l]):
                        flag = 0
                        break
    if(flag == 1):
        ans = max(sum(bit_list), ans)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <cstdlib>
#include <bitset>
#include <math.h>
#include <vector>

using namespace std;
int main(void){
    // Your code here!
    string str;
    long result = 0;
    cin >> str;
    for (int i = 0; i < pow(2,(str.length() - 1)); i++) {
        string str1 = str;
        for(int j=0; j < str1.length(); j++){
            int length = str1.length() -1 - j;
            int a = i >> length;
            if (a & 1) {
               str1.insert(j, ",");
               j++;
            }
            
        }
        
        int sum =0;
        while (str1.find(",") != -1) { 
            string re = str1.substr(sum,str1.find(",")-sum);
            result += stol(re);
            sum = str1.find(",") + 1;
            str1[str1.find(",")] = *"w";
        }
        result += stol(str1.substr(sum));
           
    }
    
    std::cout << result << std::endl;
}


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

char ary[1010];
int dp[1010][8]={};//日 J*4+O*2+I
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>ary[i];
	}
	dp[0][4]=1;
	for(int i=0;i<N;i++){
		if(ary[i]=='I')dp[i+1][1]=dp[i][1]+dp[i][3]+dp[i][5]+dp[i][7];
		if(ary[i]=='O')dp[i+1][2]=dp[i][2]+dp[i][3]+dp[i][6]+dp[i][7];
		if(ary[i]!='J')dp[i+1][3]=dp[i][1]+dp[i][2]+dp[i][3]+dp[i][5]+dp[i][6]+dp[i][7];
		if(ary[i]=='J')dp[i+1][4]=dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];
		if(ary[i]!='O')dp[i+1][5]=dp[i][1]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];
		if(ary[i]!='I')dp[i+1][6]=dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];
		dp[i+1][7]=dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];
		for(int j=0;j<8;j++){
			dp[i+1][j]%=10007;
		}
	}
	int cnt=0;
	for(int i=0;i<8;i++){
		cnt+=dp[N][i];
	}
	cout<<cnt%10007<<endl;
	return 0;
}

Measured memory_bytes: 1196
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

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

void showLand(vs land) {
	REP(i, land.size()) {
		cout << land[i] << endl;
	}
}

struct state {
	int t, x, y;
	vs land;
	state(int t, int x, int y, vs land) : t(t), x(x), y(y), land(land) {};
};

bool isProperXY(int x, int y, int n) {
	return 0<=x && x<n && 0<=y && y<n;
}

bool isDisinfectedLand(vs land, int n) {
	REP(i, n) {
		REP(j, n) {
			if(land[i][j] == '#') {
				return false;
			}
		}
	}
	return true;
}

vs updateLand(vs land, int n) {
	vs nland = land;
	REP(x, n) {
		REP(y, n) {
			int count = 0;
			REP(d, 8) {
				int nx = x+dx[d], ny = y+dy[d];
				if(isProperXY(nx, ny, n) && land[ny][nx] != '.') {
					count++;
				}
			}
			if(land[y][x] == '#' && (count == 2 || count == 3)) {
				nland[y][x] = '#';
			} else if(land[y][x] == '.' && count == 3) {
				nland[y][x] = '#';
			} else if(land[y][x] != '@') {
				nland[y][x] = '.';
			}
		}
	}
	return nland;
}

int main() {
	int n;
	while(cin >> n, n) {
		vs land(n);
		int sx, sy;
		REP(i, n) {
			cin >> land[i];
			REP(j, n) {
				if(land[i][j] == '@') {
					sy = i, sx = j;
				}
			}
		}

		queue<state> Q;
		Q.push(state(0, sx, sy, land));
		map<vs, int> memo;
		memo[land] = 1;
		int ans = -1;
		while(!Q.empty()) {
			state st = Q.front();
			Q.pop();

			if(isDisinfectedLand(st.land, n)) {
				ans = st.t;
				break;
			}

			REP(d, 8) {
				int nx = st.x+dx[d], ny = st.y+dy[d];
				if(isProperXY(nx, ny, n) && st.land[ny][nx] == '.') {
					vs nland = st.land;
					nland[st.y][st.x] = '.';
					nland[ny][nx] = '@';
					nland = updateLand(nland, n);
					if(!memo[nland]) {
						memo[nland] = 1;
						Q.push(state(st.t+1, nx, ny, nland));
					}
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 10968
N = int(input())
FizzBizz = []
Fizz = []
Bizz = []
a = 0


for i in range(1 ,N+1):
    if i % 3 == 0 and i % 5 == 0:
        FizzBizz.append(i)
    elif i % 3 == 0:
        Fizz.append(i)
    elif i % 5 == 0:
        Bizz.append(i)
    else:
        a += i

print(a)

Measured memory_bytes: 27380
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**9
eps = 10**-7

N,M = map(int,input().split())
# 1-indexed union-find
# parent(親)
par = [i for i in range(N+1)]
# rank(深さ)
rank = [0]*(N+1)
# 同グループの頂点数
# size = [1]*(N+1)

# 木の根を求める
def root(x):
    if par[x] == x:             # 根の時
        return x
    else:
        par[x] = root(par[x])   # 経路圧縮
        return par[x]

# xとyの属する集合を併合(ランク有)
def unite(x,y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y              # xの親をyに
        #size[y] += size[x]      # yの頂点数+=xの頂点数
    else:
        par[y] = x              # yの親をxに
        #size[x] += size[y]      # xの頂点数+=yの頂点数
        if rank[x] == rank[y]:
            rank[x] += 1

LRD = [tuple(map(int,readline().split())) for i in range(M)]

for (L,R,D) in LRD:
    unite(L,R)

from collections import defaultdict,deque
rel = defaultdict(lambda: [])

for (L,R,D) in LRD:
    rel[root(L)].append((L,R,D))

for k,v in rel.items():
    dist = defaultdict(lambda: [])
    for (L,R,D) in v:
        dist[L].append((R,D))
        dist[R].append((L,-D))
    que = deque([])
    x = {}
    for k1,v1 in dist.items():
        x[k1] = 0
        for (to,dis) in v1:
            x[to] = dis
            que.append(to)
        break
    while que:
        fro = que.popleft()
        for (to,dis) in dist[fro]:
            if to not in x.keys():
                x[to] = x[fro] + dis
                que.append(to)
    for (L,R,D) in v:
        if x[R] - x[L] != D:
            print('No')
            exit()
print('Yes')


    



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

char grid[103][103];

int main(){
    int a, b;
    cin >> a >> b;
    for(int i=0;i<100;++i){
        for(int j=0;j<100;++j){
            grid[i][j] = (i < 50 ? '#' : '.');
        }
    }

    int cnt = 1;
    for(int i=0;i<50;i+=2){
        for(int j=0;j<100;j+=2){
            if(cnt == a)break;
            grid[i][j] = '.';
            cnt++;
        }
        if(cnt == a)break;
    }

    cnt = 1;
    for(int i=51;i<100;i+=2){
        for(int j=0;j<100;j+=2){
            if(cnt == b)break;
            grid[i][j] = '#';
            cnt++;
        }
        if(cnt == b)break;
    }

    cout << "100 100" << endl;
    for(int i=0;i<100;++i){
        for(int j=0;j<100;++j){
            cout << grid[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    int X, N; cin >> X >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];

    ll jj = 0;

    if (count(all(p), X)==0) {
        cout << X << endl;
    }
    else {
        while (1) {
            ++jj;
            int a = X - jj;
            if (count(all(p), a)==0) {
                cout << a << endl;
                break;
            }
            int b = X + jj;
            if (count(all(p), b)==0) {
                cout << b << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Edge = pair<ll, ll>;
using Graph = vector<vector<Edge>>;

// 白0 黒1 未着色-1
vector<int> color;

Graph G;

void dfs(int v, int c) {
  color[v] = c;
    for (Edge next_v : G[v]) {
        // 隣接頂点が未着色の場合
        if (color[next_v.first] == -1) {
            if (next_v.second % 2 == 0) {
                dfs(next_v.first, c);
            }
            else {
                dfs(next_v.first, 1 - c);
            }
        }
    }
}

int main() {
    // 頂点数
    int N; cin >> N;

    // グラフ
    G.resize(N);
    for (int i = 0; i < N - 1; i++) {
        ll from, to, weight;
        cin >> from >> to >> weight;
        from--; to--;
        G[from].push_back(make_pair(to, weight));
        G[to].push_back(make_pair(from, weight));
    }
    
    color.assign(N, -1);
    dfs(0, 0);
    for (int i = 0; i < N; i++) {
        cout << color[i] << endl;
    }
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<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(T 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,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll sum=0;
    while(x&&y){
       sum+=min(2*c,a+b);
       x--; y--;
    }
    if(x){
        sum+=min(2*c,a)*x;
    }
    else{
        sum+=min(2*c,b)*y;
    }
    cout<<sum<<endl;
    return 0;
}




Measured memory_bytes: 256
# 0位置からの計算でも途中位置からの計算でも計算コストは同じ
def travelable(t, x, y):
    min_step = x + y
    if t < min_step:
        return False
    return (t - min_step) % 2 == 0

ans = None
N = int(input())
for _ in range(N):
    t_x_y = list(map(int, input().split()))
    if not travelable(t_x_y[0], t_x_y[1], t_x_y[2]):
        ans = "No"
        break
if ans is None:
    ans = "Yes"
print(ans)


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

class Mondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var W = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var S1 = 0;
        var S2 = W.Sum();
        var min = Math.Abs(S2-S1);
        for (int i=0;i<N;++i)
        {
            S1 += W[i];
            S2 -= W[i];
            var sa = Math.Abs(S2-S1);
            if (sa < min) min = sa;
        }
        Console.WriteLine(min);
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin >> n >> m;

    vector<vector<ll>> a(n,vector<ll>(m));

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    ll ans = n;

    vector<ll> id(n,0);
    vector<bool> used(m+1,false);

    for(int i = 0; i < m; i++){
        vector<ll> count(m+1,0);
        for(int j = 0; j < n; j++){
            count[a[j][id[j]]]++;
        }
        ll mm = 0;
        ll mn = 0;
        for(int j = 0; j <= m; j++){
            if(count[j] > mn){
                mn = count[j];
                mm = j;
            }
        }
        ans = min(ans,mn);
        used[mm] = true;
        for(int j = 0; j < n; j++){
            while(id[j] < m && used[a[j][id[j]]]){
                id[j]++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
*h, = map(int, input().split())
dp = [0] * N
for i in range(1, N):
    if i == 1:
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

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

vector<bool> primes;
const int MAXV = 1e5;

int main()
{
    string s;
    cin >> s;
    if (s == "ARC") {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <numeric>
using namespace std;
#define ll long long
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    char a;
    int sum=0;
    cin >> n;
    for(int i=0;i<n.size();i++){
        a=n[i];
        sum+=a-'0';
    }
    if(stoi(n)%sum==0){cout << "Yes" << endl;}
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
mode_same = False
count = 0
word = s[0]
for i in range(len(s)-1):
    if not mode_same:
        if word == s[i+1]:
            count += 1
            if i == len(s)-2:
                break
            mode_same = True
            word = s[i+1] + s[i+2]
            continue
        else:
            count += 1
            if i == len(s)-2:
                count += 1
                break
            word = s[i+1]
            continue
    if mode_same:
        mode_same = False
        if i == len(s)-2:
            count += 1
print(count)

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

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a, b;
	cin >> a >> b;
	if(a <= 8 && b <= 8){
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

[n,m]=i2()
s=i2()
t=i2()
x=10**9+7
cs=[[0 for i in range(2*10**3)]for j in range(2*10**3)]
y=0
for i in range(n):
 if s[i]==t[0]:
   y+=1
 cs[i][0]=y+0
y=0
for i in range(m):
 if s[0]==t[i]:
   y+=1
 cs[0][i]=y+0
for i in range(1,n):
 for j in range(1,m):
  if s[i]==t[j]:
   cs[i][j]=(cs[i-1][j]+cs[i][j-1]+1)%x
  else:
   cs[i][j]=(cs[i-1][j]+cs[i][j-1]-cs[i-1][j-1])%x
print((cs[n-1][m-1]+1)%x)

Measured memory_bytes: 75228
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(abs(c-a) <= d|| (abs(b-a) <=d && abs(c-b) <= d)) cout << "Yes" << endl; 
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn sub(n: u8, ub: u8) -> Vec<Vec<u8>> {
  // dbg!((n, ub));
  if n == 1 {
    return (0 .. ub).map(|x| vec![x]).collect();
  }
  let mut ret = vec![];
  for i in 0 .. ub {
    let mut ss = sub(n - 1, cmp::max(ub, i + 2));
    for v in &mut ss {
      v.push(i);
    }
    ret.append(&mut ss);
  }
  ret
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: u8,
  }
  // dbg!(&sub(n, 1));
  let ss = sub(n, 1);
  for s in &ss {
    for c in s.iter().rev() {
      puts!("{}", (c + 'a' as u8) as char);
    }
    puts!("\n");
  }
}


Measured memory_bytes: 13136
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int a,b,c;
  cin>>a>>b>>c;
  c = min(c,a+b+1);
  cout<<b+c<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i =0;i<(int)(n);i++)
#define endl '\n'
typedef pair<int,int> P;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> cnt(100000);
    for(int x=1;x<=100;x++){
        for(int y=1;y<=100;y++){
            for(int z = 1;z<=100;z++){
                cnt[x*x+y*y+z*z+x*y+x*z+y*z]++;
            }
        }
    }
    for(int i =1;i<=n;i++){
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  ll x = 0;
  while (n--) {
    int a, k; cin >> a >> k;
    while (a % k > 0 && a >= k) {
      int sub = a / k + 1;
      a -= (a - (a / k) * k + sub - 1) / sub * sub;
    }
    x ^= a / k;
  }
  cout << (x == 0 ? "Aoki\n" : "Takahashi\n");
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(){
  int i=1,n,f1,f2,f3;
  scanf("%d",&n);
  f1=0;
  f2=1;
  while(i<=n){
    f3=f2+f1;
    f1=f2;
    f2=f3;
    i++;
  }
  printf("%d\n",f2);
}



Measured memory_bytes: 2112