akhauriyash/Code-Regression huggingface dataset:
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt(),k=nxt();
    bool x[n]={false};
    rep(a,0,k)
    {
        ll p=nxt();
        while(p--)
        {
            ll b=nxt();
            x[b-1]=true;
        }
    }
    ll ans=0;
    rep(a,0,n)
        if(!x[a])
            ans++;
    cout<<ans<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3784
import java.util.Scanner;
public class Main {
    static int[]dp = new int[100000];
    static int[]stones = new int[100000];
    static int N, K;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        K = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    }
    public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            int min= Integer.MAX_VALUE;
            for(int j = 1 ; j <= K  && (i-j)>=0; ++j){
                min = Math.min(dp[i-j]+Math.abs(stones[i]-stones[i-j]),
                    min);
            }
            dp[i] = min;
        }
    }
}

Measured memory_bytes: 50324
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll L;
  cin >> L;
  ll N = (ll)floor(log2(L)) + 1;
  ll M = (N - 1) * 2;

  ll cpL = L;
  RREP(i, N - 1) {
    if (cpL - POW(2, N - 1) >= POW(2, i)) {
      M++;
      cpL -= POW(2, i);
    }
  }
  cout << N << " " << M << endl;

  REP(i, N - 1) {
    cout << i + 1 << " " << i + 2 << " " << POW(2, i) << endl;
    cout << i + 1 << " " << i + 2 << " " << 0 << endl;
  }

  RREP(i, N - 1) {
    if (L - POW(2, N - 1) >= POW(2, i)) {
      cout << i + 1 << " " << N << " " << (L - POW(2, i)) << endl;
      L -= POW(2, i);
    }
  }

  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    int i;
    foreach (c; readln.chomp.to!(char[])) {
        if (c == '+') ++i;
        if (c == '-') --i;
    }
    writeln(i);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int s1, s2, i, n = 1, s, Max, Max_num;
   scanf("%d %d", &s1, &s2);
   while ( n ) {
      Max = Max_num = 0;
      s = s1 + s2;
      if ( s > Max ) Max = s; Max_num = 0;
      for ( i = 1; i < 5; i++ ){
         scanf("%d %d", &s1, &s2);
         s = s1 + s2;
         if ( s > Max ) { Max = s; Max_num = i; }
      }
      if ( Max_num == 0 ) printf("A %d\n", Max);
      else if ( Max_num == 1 ) printf("B %d\n", Max);
      else if ( Max_num == 2 ) printf("C %d\n", Max);
      else if ( Max_num == 3 ) printf("D %d\n", Max);
      else if ( Max_num == 4 ) printf("E %d\n", Max);
      scanf("%d %d", &s1, &s2);
      if ( s1 == 0 && s2 == 0) n = 0;
   }
   return 0;
}

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


int main(){
  int n,m,i,j,ans;
  int **A;
  int *b;
  scanf("%d%d",&n,&m);
  A=malloc(n*sizeof(int *));
  for(i=0;i<n;i++){
    A[i]=malloc(m*sizeof(int));}
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&A[i][j]);}}
  b=malloc(m*sizeof(int));
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);}
  for(i=0;i<n;i++){
    ans=0;
    for(j=0;j<m;j++){
      ans=ans+ (A[i][j])*(b[j]);}
    printf("%d\n",ans);}
  return 0;}

Measured memory_bytes: 640
fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    let mut a = read_parameters::<usize>().unwrap();
    a.sort();

    let mut sum = 0;
    for x in a {
        sum = 10 * sum + x;
    }

    if sum == 557 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
const main = (input) => {
  input = input.split(' ');
  const A = parseInt(input[0], 10);
  const B = parseInt(input[1], 10);
  
  if (A+B>=24) {
    console.log(A+B-24);
  }else{
    console.log(A+B);
  }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
r=[59049,243,1,3125,1024,16807,32768,7776,0,32, \
371293,161051,100000,537824,1419857,1048576,1889568,248832,2476099,759375, \
20511149,11881376,7962624,9765625,4084101,3200000,5153632,14348907,17210368,6436343, \
33554432,60466176,28629151,69343957,79235168,52521875,24300000,45435424,90224199,39135393, \
229345007,254803968,184528125,102400000,130691232,147008443,205962976,164916224,282475249,115856201, \
601692057,418195493,459165024,380204032,312500000,345025251,714924299,503284375,550731776,656356768, \
1160290625,1350125107,916132832,1564031349,844596301,1252332576,1453933568,777600000,992436543,1073741824, \
2706784157,2887174368,3077056399,1934917632,2373046875,2535525376,2219006624,2073071593,1804229351,1680700000, \
3939040643,4437053125,4182119424,3276800000,3707398432,5277319168,5584059449,3486784401,4704270176,4984209207, \
7339040224,8587340257,6240321451,5904900000,6590815232,6956883693,7737809375,8153726976,9509900499,9039207968, \
10000000000,12762815625,11040808032,14693280768,15386239549,11592740743,14025517307,13382255776,12166529024,10510100501, \
20113571875,16105100000,17623416832,22877577568,21003416576,18424351793,21924480357,23863536599,19254145824,16850581551, \
33038369407,28153056843,27027081632,24883200000,30517578125,35723051649,34359738368,25937424601,31757969376,29316250624, \
46525874176,51888844699,41615795893,43204003424,40074642432,38579489651,44840334375,37129300000,48261724457,50049003168, \
57735339232,61917364224,71008211968,64097340625,68641485507,55730836701,66338290976,53782400000,73439775749,59797108943, \
75937500000,101621504799,78502725751,83841135993,92389579776,95388992557,89466096875,81136812032,98465804768,86617093024, \
118636749824,129891985607,108175616801,137858491849,122298103125,133827821568,115063617043,111577100832,104857600000,126049300576, \
146211169851,141985700000,159494694624,154963892093,173726604657,150536645632,168874213376,164130859375,178689902368,183765996899, \
199690286432,194264244901,188956800000,205236901143,216699865625,222620278176,210906087424,241162079949,234849287168,228669389707, \
312079600999,254194901951,274794888224,289254654976,296709280757,267785184193,304316815968,260919263232,281950621875,247609900000]
#r.sort()
x=int(input())
for i in r:
  for j in r:
    if i-j ==x:
      print("%d %d" % (int(i**0.2),int(j**0.2)))
      exit()
    if i+j ==x:
      print("%d -%d" % (int(i**0.2),int(j**0.2)))
      exit()

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

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

    map<char,int> chmp;

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

    for(int i = 0; i < s.size(); i++)
    {
        chmp[s.at(i)]++;
    }

    for(auto e:chmp)
    {
        if(e.second == 1)
        {
            cout << e.first << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

const int N = 610;

char s[N][N];
int cnt[N][N];

int calc(int x1, int y1, int x2, int y2){
    return cnt[x2][y2] - cnt[x1][y2] - cnt[x2][y1] + cnt[x1][y1];
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i){
        scanf("%s", s[i] + 1);
    }
    for (int i = 1; i <= n << 1; ++ i){
        for (int j = 1; j <= n << 1; ++ j){
            s[i][j] = s[(i - 1) % n + 1][(j - 1) % n + 1];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++ i){
        int sz = 2 * n - 1 - i;
        for (int j = 1; j <= sz; ++ j){
            for (int k = 1; k <= sz; ++ k){
                cnt[j][k] = s[j][i + k] == s[k][i + j];
            }
        }
        for (int j = 1; j <= sz; ++ j){
            for (int k = 1; k <= sz; ++ k){
                cnt[j][k] += cnt[j][k - 1];
            }
        }
        for (int k = 1; k <= sz; ++ k){
            for (int j = 1; j <= sz; ++ j){
                cnt[j][k] += cnt[j - 1][k];
            }
        }
        for (int j = 1; j <= n - i; ++ j){
           ans += calc(j - 1, j - 1, j + n - 1, j + n - 1) == n * n;
        }
    }
    for (int i = 1; i < n; ++ i){
        int sz = 2 * n - 1 - i;
        for (int j = 1; j <= sz; ++ j){
            for (int k = 1; k <= sz; ++ k){
                cnt[j][k] = s[i + j][k] == s[i + k][j];
            }
        }
        for (int j = 1; j <= sz; ++ j){
            for (int k = 1; k <= sz; ++ k){
                cnt[j][k] += cnt[j][k - 1];
            }
        }
        for (int k = 1; k <= sz; ++ k){
            for (int j = 1; j <= sz; ++ j){
                cnt[j][k] += cnt[j - 1][k];
            }
        }
        for (int j = 1; j <= n - i; ++ j){
           ans += calc(j - 1, j - 1, j + n - 1, j + n - 1) == n * n;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define int long long
using namespace std;
main(){
    int a,b;
    cin>>a>>b;
    int tmp=__gcd(a,b);
    int pos=sqrt(tmp);
    int ans=0;
    for(int i=2;i<=pos;++i){
        if(tmp%i==0){
        ans++;
        while(tmp%i==0){
            tmp/=i;
        }
        }
    }
    if(tmp!=1)ans++;
    cout<<ans+1<<endl;
}


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

int main()
{
  int64_t N, D, A, x, h, ans = 0;
  cin >> N >> D >> A;
  vector<pair<int64_t, int64_t>> xh(N);
  for (int i = 0; i < N; i++)
  {
    cin >> x >> h;
    xh[i] = {x, h};
  }
  sort(xh.begin(), xh.end());
  int64_t total = 0;
  queue<pair<int64_t, int64_t>> Q;
  for (int i = 0; i < N; i++)
  {
    tie(x, h) = xh[i];
    while (Q.size() && Q.front().first < x)
    {
      total -= Q.front().second;
      Q.pop();
    }
    h -= total;
    if (h > 0)
    {
      int64_t n = (h + A - 1) / A;
      ans += n;
      int64_t damage = n * A;
      total += damage;
      Q.emplace(x + 2 * D, damage);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8000
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int H, N, sum=0, A;
	cin >> H >> N;
	rep(i, N)
	{
		cin >> A;
		sum += A;
	}

	if(sum>=H) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 253500
#define F first
#define S second

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
ll a[maxn],s[maxn],n,k,ans,r;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
    sort(s,s+n+1); r=1;
    for(int i=1;i<=n;i++) if (s[i]!=s[i-1]) ans+=r*(r-1),r=1; else r++;
    ans+=r*(r-1);
    cout << ans/2 << endl;
    return 0;
}



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

int	main()
{
	string	S;
	cin >> S;
	set<char>	c_set;
	for (char c : S)
		c_set.insert(c);
	bool	is_found = false;
	for (char c = 'a'; c <= 'z'; ++c) {
		if (!c_set.count(c)) {
			cout << c << endl;
			is_found = true;
			break;
		}
	}
	if (!is_found)
		cout << "None" << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    unordered_map<char, char> mp;
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['G'] = 'C';
    mp['C'] = 'G';

    var(char, b);
    output(mp[b]);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

struct list{
	int a;
	struct list *prev;
	struct list *next;
};
struct list *head,*tail;

struct list *make(int a){
	struct list *p;
	p=malloc(sizeof(struct list));
	p->a=a;
	p->prev=NULL;
	p->next=NULL;
	return p;
}

int main(void){
	int n=in(),i,a;
	struct list *p;
	a=in();
	head=tail=make(a);
	rep(i,n-1){
		a=in();
		p=make(a);
		if(!(i%2)){
			tail->next=p;
			p->prev=tail;
			tail=p;
		}
		else{
			p->next=head;
			head->prev=p;
			head=p;
		}
	}
	if(!(n%2)){
		for(p=tail;p->prev!=NULL;p=p->prev)
			printf("%d ",p->a);
		print(p->a);
	}
	else{
		for(p=head;p->next!=NULL;p=p->next)
			printf("%d ",p->a);
		print(p->a);
	}
	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n,x;
  cin >> n >> x;
  int mn = 1001001001;

  rep(i,n) {
    int a;cin >> a;
    x -= a;
    mn = min(mn,a);
  }
  cout << n + x / mn << endl;

  return 0;
}


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

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

  int s = X;
  X = Y;
  Y = s;

  int t = X;
  X = Z;
  Z = t;

  cout << X << " "<< Y << " "<< Z;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using Int = int64_t;
vector<bool> prime_table(Int n) {
    vector<bool> prime(n + 1, true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;
    for(Int i = 2; i * i <= n; i++) {
        if(!prime[i]) continue;
        for(Int j = i + i; j <= n; j += i) prime[j] = false;
    }
    return prime;
}
int main() {
    auto primes = prime_table(200000);
    Int X;
    cin >> X;
    cout << distance(primes.cbegin(), find(primes.cbegin() + X, primes.cend(), true)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec H(N); cin >> H;
    H.pb(INF);

    int ans = 0;
    int tmp = 0;
    REP(i, N){
        if(H[i] >= H[i + 1]) tmp++;
        else{
            Max(ans, tmp);
            tmp = 0;
        }
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int n, k, x;
    int i, o;

    scanf("%d %d", &n, &k);
    for(i = o = 0; i < n; i ++)
    {
        scanf("%d", &x);
        o += x >= k;
    }
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
 
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
 
long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }
 
void main()
{
	auto N = RD!ulong;
	auto K = RD!ulong;
	auto A = RDR.split.to!(ulong[]);
 
	ulong[64] bitCnt;
	foreach (e; A)
	{
		foreach (i; 0..64)
		{
			if (e & (cast(ulong)1 << i)) ++bitCnt[i];
		}
	}
 
	ulong x;
	ulong ans;
	foreach_reverse (i; 0..64)
	{
		if (bitCnt[i] > N / 2) continue;
 
		ulong bit = cast(ulong)1 << i;
		if (x + bit <= K) x += bit;
	}
 
	foreach (e; A)
	{
		ans += e ^ x;
	}
 
	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 4860
import java.util.*;

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

        while (true) {
            int m = scan.nextInt(), f = scan.nextInt(), r = scan.nextInt();
            if (m == -1 && f == -1 && r == -1) {
                break;
            }

            if (m == -1 || f == -1) {
                System.out.println("F");
            } else if (m + f >= 80) {
                System.out.println("A");
            } else if (m + f >= 65 && m + f < 80) {
                System.out.println("B");
            } else if (m + f >= 50 && m + f < 65) {
                System.out.println("C");
            } else if (m + f >= 30 && m + f < 50) {
                if (r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else if (m + f < 30) {
                System.out.println("F");
            }
        }
    }
}

Measured memory_bytes: 26236
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
 	int l, r, d;
  	cin >> l >> r >> d;
  	int cnt = 0;
  
  	int prod = 0;
   //5 10 2
  
  	int num = 0;
 	while(prod <= r) {
      if(prod >=l && prod <=r)
	      ++cnt;
      ++num;
      prod = d*num;
      
    }
  
  cout << cnt << endl;
  
}

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


int main (){
    
    int N,L;
    cin >> N >> L;
    string S[N],ans;
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    
    sort(S,S+N);
    ans = S[0];
    for(int i = 1; i < N; i++) {
        ans += S[i];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 20;
char cn[cm], *ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint();
	int A = 0, B = 0, AN = 1, BN = 0;
	A = getint();
	int dame = 0;
	rep(i, N - 1) {
		int a = getint();
		if (!B) {
			if (A == a) AN++;
			else if (abs(a - A) == 1) {
				B = a;
				BN++;
				if (A < B) {
					swap(A, B);
					swap(AN, BN);
				}
			}
			else dame = 1;
		}
		else {
			if (A == a) AN++;
			else if (B == a) BN++;
			else dame = 1;
		}
	}

	if (dame) co("No");
	else if (B == 0 && A == N - 1) co("Yes");
	else {
		A -= BN;
		if (A <= 0) co("No");
		else if (A * 2 > AN) co("No");
		else co("Yes");
	}

	Would you please return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007  
#define FOR(a, b, c) for (ll(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (ll(a) = (b); (a) <= (c); ++(a)) 

#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define TC(t) while (t--) 

void dTb(ll n,vl &v) 
{ 
    // Size of an integer is assumed to be 32 bits 
    for (ll i = 0; i < 20; i++) { 
        v[i] = n&1;
	n = n>>1;
  } 
} 



int main()
{
    fast;
    ll i,j,k,n,t,q,r,c,x;
    cin>>n;
    vvl vec(20), vv(n,vl(20));    
    REP(i,n) { 
        cin>>k;
        dTb(k,vv[i]);
        REP(j,20){
            if(vv[i][j]){
                vec[j].pb(i);
            }
        }
    }
    ll ind,mx;
    ll ans = 0;
    REP(i,n)
    {
        mx = n-1;
        REP(j,20)
        {
            if(vec[j].size() == 0){ continue; }
            
            ind = upper_bound(ALL(vec[j]), i) - vec[j].begin();
            if(ind == vec[j].size()){ continue; }
            if(vec[j][ind] > mx){ continue; }
            
            if(vv[i][j])
                mx = vec[j][ind] - 1; 
            else
            {
                if((ind + 1) == vec[j].size() ){ continue; }
                if(vec[j][ind+1] > mx) { continue; }
                mx = vec[j][ind+1] - 1;
            }
        }
        ans += mx - i;
    }
    cout<<ans+n;
}	

Measured memory_bytes: 55092
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
mod=10**9+7
def factorial(x): #階乗計算
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): #約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): #素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n=int(input())
    m=0
    while n>(m*(m+1))//2:
        m+=1
    for i in range(m):
        i+=1
        if not i == (m*(m+1))//2 - n:
            print(i)

main()

Measured memory_bytes: 42344
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int k=sc.nextInt();
		Unionfind uf=new Unionfind(n);
		int[] count=new int[n];
		for(int i=0; i<m; i++){
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			uf.unite(a,b);
			count[a]++;
			count[b]++;
		}
		int[] mai=new int[n];
		for(int i=0; i<k; i++){
			int c=sc.nextInt()-1;
			int d=sc.nextInt()-1;
			if(uf.root(c)==uf.root(d)){
				mai[c]--;
				mai[d]--;
			}
		}
		for(int i=0; i<n; i++){
			System.out.print(uf.size(i)-count[i]-1+mai[i]+" ");
		}
	}
	static class Unionfind{
		int[] parent;
		int[] size;
		public Unionfind(int n){
			this.parent=new int[n];
			this.size=new int[n];
			for(int i = 0; i<n; i++){
				parent[i]=i;
				size[i]=1;
			}
		}
		public int root(int t){
			if(parent[t]==t){
				return t;
			}else{
				return parent[t]=root(parent[t]);
			}
		}
		public void unite(int x,int y){
			if(same(x,y)){
				return;
			}
			int xroot = root(x);
			int yroot = root(y);
			parent[yroot]=xroot;
			size[xroot]+=size[yroot];
			size[yroot]=0;
		}
		public int size(int i){
			return size[root(i)];
		}
		public boolean same(int x,int y){
			return root(x)==root(y);
		}
	}
}


Measured memory_bytes: 114204
from collections import deque
h, w = map(int, input().split())
c_h, c_w = map(int, input().split())
d_h, d_w = map(int, input().split())
#スタートとゴールの座標を設定
start_h = c_h - 1
start_w = c_w - 1
goal_h = d_h - 1
goal_w = d_w - 1
#迷路の読み込み
maze = [input() for _ in range(h)]
inf = float("inf")
dist = [[inf] * w for _ in range(h)]



def bfs(x, y):
    dist[x][y] = 0
    q = deque()
    q.append((x, y))
    while q:
        x, y = q.popleft() 
        d = dist[x][y]
        for dx, dy in [(0,1),(1,0),(0,-1),(-1,0)]:
            nx = x + dx
            ny = y + dy 
            if not 0 <= nx < h or not 0 <= ny < w:
                continue
            if maze[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d:
                continue
            dist[nx][ny] = d           
            q.appendleft((nx, ny))

        for dxx in range(-2, 3):
            for dyy in range(-2, 3):
                 nxx = x + dxx
                 nyy = y + dyy 
                 if not 0 <= nxx < h or not 0 <= nyy < w:
                    continue
                 if maze[nxx][nyy] == "#":
                    continue
                 if dist[nxx][nyy] <= d+1:
                    continue
                 dist[nxx][nyy] = d+1
                 q.append((nxx, nyy))
                



bfs(start_h, start_w)
if dist[goal_h][goal_w] == inf:
    print("-1")
else:
    print(dist[goal_h][goal_w])    

Measured memory_bytes: 106012
from itertools import combinations

H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(map(int, input())))

separators = []
for i in range(2 ** (H - 1)):
    separators.append([(i >> j) & 1 for j in range(H - 1)])
separators.sort(key=sum)

for i in range(len(separators)):
    ids = [0]
    for j in separators[i]:
        ids.append(ids[-1] + j)
    separators[i] = ids

min_ = H - 1 + W - 1
for ids in separators:
    size = ids[-1] + 1
    nums = [0] * size
    num_cuts = size - 1
    if min_ <= num_cuts:
        continue
    for row in range(H):
        nums[ids[row]] += S[row][0]
    if any(K < n for n in nums):
        continue
    ignore = False
    for col in range(1, W):
        adds = [0] * size
        for row in range(H):
            adds[ids[row]] += S[row][col]
        if any(K < nums[i] + adds[i] for i in range(size)):
            if any(K < a for a in adds):
                ignore = True
                break
            num_cuts += 1
            if min_ <= num_cuts:
                ignore = True
                break
            for i in range(size):
                nums[i] = adds[i]
        else:
            for i in range(size):
                nums[i] += adds[i]
    if not ignore:
        min_ = min(num_cuts, min_)
print(min_)

Measured memory_bytes: 51548
import scala.io.Source.stdin

object Main extends App {
  var b = new StringBuilder

  def loop(l:List[String],s:List[String]):Unit =
    if(l == Nil) return
    else {
      val i::lines = l
      if(i == "0") {
        val hd::tl = s
        b.append(hd+"\n")
        loop(lines,tl)
      } else {
        loop(lines,i::s)
      }
    }

  loop(stdin.getLines.toList,Nil)
  print(b.result)
}

Measured memory_bytes: 43940
#include<stdio.h>

int main() {
int a, b, c, d;
scanf ("%d", &a);
scanf ("%d", &b);
scanf ("%d", &c);
scanf ("%d", &d);
if (a>=b){
    a=b;
}
if (c>=d){
    c=d;
}
printf ("%d", a+c);
return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> tree(n);
    vector<pair<int, int>> ab(n-1);
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b, a--, b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
        ab[i] = make_pair(a, b);
    }

    vector<int> derivec(n);
    vector<int> visit(n);
    map<pair<int, int>, int> mapc;
    int cnum = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int tmp = q.front(); q.pop();
        visit[tmp] = true;
        if (cnum < (int) tree[tmp].size()) cnum = tree[tmp].size();

        int color = 1;
        for (auto& e : tree[tmp]) {
            if (visit[e]) continue;
            if (derivec[tmp] == color) color++;
            derivec[e] = mapc[make_pair(tmp, e)] = mapc[make_pair(e, tmp)] = color++;
            q.push(e);
        }
    }

    cout << cnum << endl;
    for (auto& e : ab) cout << mapc[e] << endl;
}


Measured memory_bytes: 20096
#include <stdio.h>
int pa(void)
{
    printf("A\n");
}

int pb(void)
{
    printf("B\n");
}

int pc(void)
{
    printf("C\n");
}

int main(void)
{
    int n, i,sum, pm[10000], pj[10000], pe[10000];
    while(1) {
	scanf("%d", &n);
	if (n == 0) {
	    break;
	}
	sum = pm[i] + pe[i] + pj[i];
	for (i = 0; i < n; i++) {
	    scanf("%d %d %d", &pm[i], &pj[i], &pe[i]);
	    sum = pm[i] + pe[i] + pj[i];
	    if (pm[i] == 100 || pj[i] == 100 || pe[i] == 100) {
		pa();
	    } else if (pm[i] + pe[i] >= 180) {
		pa();
	    } else if (sum >= 240) {
		pa();
	    } else if (sum >= 210) {
		pb();
	    } else if (sum >= 150 && (pm[i] >= 80 || pe[i] >= 80)) {
		pb();
	    } else {
		pc();
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a[333][333],b[333][333];
int check(int x)
{
	int i,j;
	for(i=1;i<=x;i++)
	{
		for(j=1;j<=x;j++)
		{
			if(a[i][j]!=a[j][i])
				return 0;
		}
	}
	return x;
}
int main()
{
	int n,i,k,j,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s",a[i]+1); 
	}
	for(i=0;i<n;i++)
	{
		for(j=1;j<=n;j++)
		{
			for(k=1;k<=n;k++)
			{
				if(j==n)
					b[j][k]=a[1][k];
				else
					b[j][k]=a[j+1][k]; 
			}
		}
		for(j=1;j<=n;j++)
		{
			for(k=1;k<=n;k++)
			{
				a[j][k]=b[j][k];
			}
		}
		ans+=check(n);
	}
	printf("%d",ans);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


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

int main(void) {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i <= h + 1; i++) {
        for (int j = 0; j <= w + 1; j++) {
            if (i == 0 || i == h + 1 || j == 0 || j == w + 1) cout << '#';
            else {
                char a;
                cin >> a;
                cout << a;
            }
            if (j == w + 1) cout << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<string,string> pss;
vector<pss> vpss;
bool used;
string s;
ll maxdif=-1000;
string ans="0";
vector<string> cands;
void getnum(string makenum,int count,int last)
{
  if(count==0)
    {
      cands.push_back(makenum);
    }
  else
    {
      for(int i=last+1;i<10;i++)
	{
	  string newnum=makenum+to_string(i);
	  getnum(newnum,count-1,i);
	}
    }
}


int main(void)
{
  cin >> s;
  int ssize=int(s.size());
  string tmp="";
  ll n10=10;
  for(int i=0;i<ssize-1;i++)
    {
      n10*=10;
    }
  getnum(tmp,ssize,-1);
  for(int i=0;i<cands.size();i++)
    {
      //cout << cands[i] << endl;
      //cout << endl;
      do{
	string tmp=cands[i];
	//cout << tmp << endl;
	ll newpass=stoll(cands[i]);
	ll dif=min(abs(stoll(s)-newpass),n10-abs(stoll(s)-newpass));
	if(dif==maxdif)
	  {
	    maxdif=dif;
	    if(ans=="0")
	      {
		ans=cands[i];
	      }
	    if(stoll(cands[i])<stoll(ans))
	      {
		ans=cands[i];
	      }
	  }
	if(dif>maxdif)
	  {
	    maxdif=dif;
	    ans=cands[i];	
	  }
	
      }while(next_permutation(cands[i].begin(),cands[i].end()));
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3284
class UnionFind():
    def __init__(self,n):
        self.parent = [-1 for _ in range(n)]

    def size(self,x):
        return -self.parent[self.find(x)]

    def find(self,x):
        if(self.parent[x]<0):
            return x
        else:
            self.parent[x]=self.find(self.parent[x])
            return self.parent[x]

    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return False
        if(self.size(x)<self.size(y)):
            self.parent[y]+=self.parent[x]
            self.parent[x]=y
        else:
            self.parent[x]+=self.parent[y]
            self.parent[y]=x
        return True

    def same(self,x,y):
        return self.find(x)==self.find(y)

N,M = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
un = UnionFind(N)
for _ in range(M):
    x,y = [int(x) for x in input().split()]
    un.unite(x-1,y-1)
cnt = 0
for ind,i in enumerate(p):
    if(un.same(ind,i-1)):
        cnt+=1
print(cnt)


Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

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

	int N; cin >>N;
	vl A(N); vin(A);

	bool in = false, de = false;
	ll money = 1000;
	bool have = false;
	rep1(i,N){
		if(A[i-1] < A[i]) {money += (money / A[i-1]) * (A[i] - A[i-1]);}
		//cout << money << endl;
	}
	cout << money << endl;

}

Measured memory_bytes: 3656
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		if (s.equals("AAA") || s.equals("BBB"))
			System.out.println("No");
		else 
			System.out.println("Yes");
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define np(str) next_permutation(str.begin(),str.end())
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e8 ;
ll INF = 1e12;

ll n, m;

int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;

	cin >> n;
	ll a[n];
	rep(i, n)
	cin >> a[i];
	sort(a, a + n);
	ll cnt = 0;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			for (k = j + 1; k < n; k++) {
				if (a[i] != a[j] && a[j] != a[k]) {
					if (a[i] + a[j] > a[k]) {
						cnt++;
					}
				}
			}
		}
	}
	cout << cnt;

	return 0;
}

Measured memory_bytes: 3692