akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        char[] a = in.ns().toCharArray();
        char[] b = in.ns().toCharArray();
        char[] c = in.ns().toCharArray();
        int i = 0, j = 0, k = 0;
        char ans = 'a';
        while(true){
            if(ans=='a'){
                if(i >= a.length) break;
                else{
                    ans = a[i];
                    i++;
                }
            }else if(ans=='b'){
                if(j >= b.length) break;
                else{
                    ans = b[j];
                    j++;
                }
            }else{
                if(k >= c.length) break;
                else{
                    ans = c[k];
                    k++;
                }
            }
        }
        out.println((char)(ans+'A'-'a'));
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n; cin >> n;
  ld ans = n;
  ans /= 3;
  cout << (ans*ans*ans) << nl;
  return 0;
}



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

// zero-based numbering
template<class T> struct FenwickMin {
    vector<T> bit; int N, I;
    FenwickMin(int n, int init) : N(n), I(init) { bit.assign(n+1, init); }
    // add w to a
    void add(int a, T w) {
        for (int x = ++a; x <= N; x += x & -x) bit[x] = min(bit[x], w);
    }
    // range_min [0, a)
    T range_min(int a) {
        T ret = I;
        for (int x = a; x > 0; x -= x & -x) ret = min(ret, bit[x]);
        return ret;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long N, Q; cin >> N >> Q;
    FenwickMin<long long> H(N, N-2), W(N, N-2);
    long long Ans = (N-2) * (N-2);
    
    auto query = [&N](long long x, auto &H, auto &W) {
        auto U = H.range_min(N-x+1);
        W.add(N-U-1, x-2);
        return U;
    };

    while (Q--) {
        int type; long long x; cin >> type >> x;
        if (type == 1) Ans -= query(x, H, W);
        else Ans -= query(x, W, H);
    }
    cout << Ans << "\n";
    return 0;
}

Measured memory_bytes: 6348
#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 2147483647
#define LLINF 9223372036854775807LL
#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 TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);
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() {
    INIT;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n,r;
  cin>>n>>r;
  cout<<r+100*(10-min(10,n))<<endl;
  return 0;
}


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

const int maxN = 2005, mod = 1e9 + 7;

int n, m, k, len, ans;
int f[maxN * 2 + 1][maxN + 1][2], sum[maxN * 2 + 1][maxN + 1];

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	len = (n + m - 1) / (k - 1);
	f[0][0][0] = 1;
	for(int i = 0; i <= m; i++) sum[0][i] = 1;
	for(int i = 1; i <= len; i++)
		for(int j = 0; j <= m; j++)
		{
			f[i][j][0] = ADD(f[i - 1][j][0], f[i - 1][j][1]);
			if(j) f[i][j][1] = SUB(sum[i - 1][j - 1], j >= k ? sum[i - 1][j - k] : 0);
			int t = (i - 1) * (k - 1) + k - j;
			if(j <= m && j % (k - 1) == m % (k - 1) && t <= n && t % (k - 1) == n % (k - 1)) 
				ans = ADD(ans, f[i][j][1]);
			if(j) sum[i][j] = sum[i][j - 1];
			sum[i][j] = ADD(sum[i][j], ADD(f[i][j][0], f[i][j][1]));
		}
	printf("%d", ans);
	return 0;
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
const int e5 = (int) 1e5 + 5;
//const int MOD = (int) 1e9 + 7;
const int MOD = (int) 998244353;
//int MOD = 998244353;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL mod = MOD)
{
    if(n < 0) a = fp(a, mod - 2, mod), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % mod) if(n & 1) res = res * a % mod; return res;
}

struct Mint
{
    int x;
    Mint() {x = 0;}
    Mint(int _x): x(_x) {if(x < 0 || x >= MOD) x = (x % MOD + MOD) % MOD;}
    Mint(LL _x): x(_x) {if(x < 0 || x >= MOD) x = (x % MOD + MOD) % MOD;}
    Mint operator - () const{
        return Mint(MOD - x);
    }
    Mint operator + (const Mint &rhs) const{
        return Mint(x + rhs.x >= MOD ? x + rhs.x - MOD : x + rhs.x);
    }
    Mint operator - (const Mint &rhs) const{
        return Mint(x - rhs.x < 0 ? x - rhs.x + MOD : x - rhs.x);
    }
    Mint operator * (const Mint &rhs) const{
        return Mint((LL)x * rhs.x % MOD);
    }
    Mint operator / (const Mint &rhs) const{
        return Mint(x * fp(rhs.x, -1) % MOD);
    }
    Mint& operator += (const Mint &rhs) {
        x += rhs.x; if(x >= MOD) x -= MOD; return *this;
    }
    Mint& operator *= (const Mint &rhs) {
        x = ((LL)x * rhs.x) % MOD; return *this;
    }
    bool operator == (const Mint &rhs) const{
        return x == rhs.x;
    }
    bool operator != (const Mint &rhs) const{
        return x != rhs.x;
    }
    friend ostream& operator << (ostream &out, const Mint &rhs){
        return out << rhs.x;
    }
    friend istream& operator >> (istream &in, Mint &rhs){
        return in >> rhs.x;
    }
};


const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;


int ans[maxn];

void work()
{
    int n;
    cin >>n;
    for(int i = 2; i <= n; i++)
    {
        int x; read(x);
        ans[x]++;
    }

    for(int i = 1; i <= n; i++) cout <<ans[i] <<endl;
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 4304
#include "bits/stdc++.h"
using namespace std;
//template <typename... T> void read(T& ... t){ ((cin >> t), ...); }
//template <typename... T> void write(T ... t){ ((cout << t), ...); }
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define space ' '
using LL = long long;
using pii = pair<int,int>;
const int INF = 2e9;
const int NN = 2e3;
const int MOD = 998244353;
namespace Mm{
	inline LL _chk(const LL &x){ return (x < MOD) ? x : (x-MOD < MOD) ? x-MOD : x%MOD; }
	inline LL mul(const LL &x, const LL &y) { return ((LL)x*y)%MOD; }
	inline LL add(const LL &x, const LL &y) { return ((LL)x+y)%MOD; }
	inline LL power(const LL &x, const LL &n){ if(n == 0) return 1; LL y=power(x, n>>1); y=mul(y,y); return (n&1)?mul(y,x):y; }
	inline LL inv(const LL &x){ return power(x, MOD-2); }
	LL _fact[2*NN] = {0};
	inline LL fact(const LL &x){ return (x == 0 ? 1 : (_fact[x] != 0 ? _fact[x] : _fact[x]=mul(x, fact(x-1)))); }
	LL _cnk[2*NN+1][2*NN+1] = {0};
	inline LL cnk(const LL &n, const LL &k){ return (n<k) ? 0 : _cnk[n][k]; }
} using namespace Mm;
int n,k;
int dp[NN+1][NN+1];
int nbPairs[2*NN+1];

#define read(a,b) cin>>a>>b
#define write(a,b) cout<<a<<b

int32_t main(){ FAST;
	for(int a=0; a<=2*NN; ++a) for(int b=0; b<=2*NN; ++b){
		if(b > a) _cnk[a][b] = 0;
		else if(b == 0) _cnk[a][b] = 1;
		else _cnk[a][b] = add(_cnk[a-1][b], _cnk[a-1][b-1]);
	}

	read(k,n);
	dp[0][0] = 1;
	for(int i=1; i<=NN; ++i){ // #pairs
		int prefSum = 0;
		for(int j=0; j<=NN; ++j){ // #items to distribute on pairs
			dp[i][j] = add(dp[i-1][j], add(prefSum, prefSum)); // k € [1;j]
			prefSum = add(prefSum, dp[i-1][j]);
		}
	}

	for(int i=1; i<=k; ++i) for(int j=i+1; j<=k; ++j) ++nbPairs[i+j];

	for(int i=2; i<=2*k; ++i){
		int ans = 0;
		int others = k - 2*nbPairs[i];

		if(i&1){
			if(others == 0){
				ans = dp[nbPairs[i]][n];
				write(ans, ln);
				continue;
			}

			for(int giveOthers=0; giveOthers<=n; ++giveOthers){
				int givePairs = n-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
		}
		else{
			--others;
			if(others == 0){
				ans = add(dp[nbPairs[i]][n], dp[nbPairs[i]][n-1]);
				write(ans, ln);
				continue;
			}
			
			for(int giveOthers=0; giveOthers<=n; ++giveOthers){
				int givePairs = n-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
			for(int giveOthers=0; giveOthers<=n-1; ++giveOthers){
				int givePairs = n-1-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
		}

		write(ans, ln);
	}
}

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

template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  sort(A.begin(), A.end());

  int ans = 1001001001;
  for (int i = 0; i < N - K + 1; i++)
  {
    chmin(ans, abs(A.at(i) - A.at(i + K - 1)));
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	long long n, m, ans = 0; cin >> n >> m;
	if (n * 2 >= m) {
		cout << m / 2 << endl;
		return 0;
	}
	ans += n;
	m -= n * 2;
	ans += m / 4;
	cout << ans << endl;
}


Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
long long n, s;
long long v[51];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	for (int i = 1; i < n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			s += v[i] * v[j];
		}
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        String str[]=br.readLine().split(" ");
        long arr[]=new long[n];
        long xor=0;
        for(int i=0;i<n;i++)
        {
            arr[i]=Long.parseLong(str[i]);
            xor^=arr[i];
        }
        for(int i=0;i<n;i++)
        pw.print((xor^arr[i])+" ");
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 64752
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main (String[] args) {

		Main main = new Main ();
		main.solve();
	}

	private void solve() {

		Scanner sc = new Scanner (System.in);

		long N = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long e = sc.nextLong();

		long ar = N/a;
		if (N%a!=0) {
			ar++;
		}
		long br = N/b;
		if (N%b!=0) {
			br++;
		}
		long cr = N/c;
		if (N%c!=0) {
			cr++;
		}
		long dr = N/d;
		if (N%d!=0) {
			dr++;
		}
		long er = N/e;
		if (N%e!=0) {
			er++;
		}

		long[] list = new long [5];
		list[0]=ar;
		list[1]=br;
		list[2]=cr;
		list[3]=dr;
		list[4]=er;
		Arrays.sort(list);

		long time = list[4]+4;

		System.out.println(time);

	}
}

Measured memory_bytes: 23892
<?php
  fscanf(STDIN, "%d", $len);
  fscanf(STDIN, "%s", $str);

  $cnt = 0;

  while(preg_match('/ABC/', $str)) {
    $cnt++;
    $str = strstr($str, 'ABC');
    $str = substr($str, 3);
  }

  echo $cnt;

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

int main()
{
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  int64_t ans = 0;
  ans += A.at(0) / 2;
  A.at(0) %= 2;
  for (int i = 1; i < N; i++)
  {
    if (A.at(i - 1) && A.at(i) > 0)
    {
      ans++;
      A.at(i)--;
    }
    ans += A.at(i) / 2;
    A.at(i) %= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == N) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  int n,m;
  cin >> n >> m;
  int l = 0;;
  int r = inf;
  rep(i,m){
    int p,q;
    cin >> p >> q;
    
    l = max(l,p);
    r = min(r,q);
  }
  cout << max(0,r-l+1) << endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    private static int[] fact;

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

        int N = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(solve(N, a, b));
    }

    private static long solve(int N, int a, int b) {
        long sum = power(2, N, MOD) - 1;

        sum = mod(sum - combination(N, a, MOD), MOD);
        sum = mod(sum - combination(N, b, MOD), MOD);

        return mod(sum, MOD);
    }

    public static long power(long base, long t, long p) {
        long ans = 1;

        while (t > 0) {
            if (t % 2 == 1) {
                ans = ans * base % p;
            }

            t /= 2;
            base = base * base % p;
        }

        return ans;
    }

    public static long combination(int n, int r, int p) {
        if (n == 0 && r == 0) return 1;
        if (n < r || n < 0)   return 0;

        r = Math.min(r, n-r);
        long x = 1;
        long y = 1;
        for (int i=1; i<=r; i++) {
            x = x * (n-i+1) % p;
            y = y * i % p;
        }

        return mod(x * power(y, p-2, p), p);
    }

   public static long mod(long a, long p) {
        return (a%p + p) % p;
    }
}

Measured memory_bytes: 23636
N,M=map(int,input().split())
need=[tuple(map(int,input().split())) for i in range(M)]
need.sort(key=lambda x:x[0])
ans=0
bef=0
for a,b in need:
    if a<=bef:
        bef=min(b-1,bef)
    else:
        ans+=1
        bef=b-1
print(ans)

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 607;

int n;
char s[MAXN][MAXN];
int ml[MAXN][MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d", &n );
	lpi ( i, 1, n ) scanf ( "%s", s[i] + 1 );
}

void work ()
{
	// main work

	lpi ( i, 1, n ) lpi ( j, 1, n ) s[i + n][j] = s[i][j + n] = s[i + n][j + n] = s[i][j];

	lpi ( i, 1, n ) {
		lpi ( j, 1, n ) {
			ml[i][j] = 1;
			while ( ml[i][j] < n && s[i + ml[i][j]][j] == s[i][j + ml[i][j]] ) ++ml[i][j];
		}
	}

	int ans = 0;
	bool flag;
	lpi ( i, 1, n ) {
		lpi ( j, 1, n ) {
			flag = true;
			lp ( k, 0, n ) {
				if ( ml[( i + k - 1 ) % n + 1][( j + k - 1 ) % n + 1] < n - k ) {
					flag = false;
					break;
				}
			}
			if ( flag ) ++ans;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<algorithm>
using namespace std;


int main(){
  int s[551], minus = 0, n;
  long long int res = 1;
  scanf("%d", &n);
  for(int i = 0;i < n;i++)
    scanf("%d", s + i);
  sort(s, s + n);
  for(int i = n - 1;i >= 0;i--,minus++){
    res += max(0, s[i] - minus / 4);
  }
  printf("%lld\n", res );
  return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
const int maxn=2e5+5;
ll n,a[maxn],len,ans,cnt;
string s;
signed main()
{
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>s;
    len=s.length();
    for(int i=0;i<=len-1;i++)
    {
        if(s[i]=='S')
        {
            ans=max(ans,cnt);
            cnt=0;
        }
        else
        {
            cnt++;
        }
    }
    if(cnt!=0)
    {
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,temp,sum=0;
  cin>>n;
  temp=n;
  while(n){
    sum+=n%10;
    n/=10;
  }
  if(temp%sum==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 256
matrix = []
vector = []
n, m = [int(x) for x in input().split()]

for i in range(n):
    matrix.append([int(x) for x in input().split()])
for i in range(m):
    vector.append(int(input()))

for i in range(n):
    sum = 0
    for j in range(m):
        sum += matrix[i][j] * vector[j]
    print(sum)

Measured memory_bytes: 8076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1
{
    class ITP1_3_D
    {
        static void Main(string[] args)
        {
            int a, b, c;
            int divisor_count = 0;

            List<int> dataSet = Console.ReadLine().Split().Select(int.Parse).ToList();

            a = dataSet[0];
            b = dataSet[1];
            c = dataSet[2];

            for (int i = a; i <= b; i++)
            {
                if ((c % i) == 0)
                {
                    divisor_count++;
                }
            }

            Console.WriteLine(divisor_count);
            Console.ReadLine();
        }
    }
}



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

int g[105][105];

void dfs(int a,int b,int p)
{
	if(g[a][b]!=p)return;

	g[a][b]=-1;

	dfs(a+1,b,p);
	dfs(a-1,b,p);
	dfs(a,b+1,p);
	dfs(a,b-1,p);
	}

int main()
{
	int w,h,sx,sy,gx,gy,n;
	while(true)
	{	
		for(int i=0;i<105;i++){
			for(int j=0;j<105;j++){
				g[i][j]=0;
				}
			}

		cin >> w >> h;
		if(w==0&&h==0)break;
		cin >> sx >> sy;
		cin >> gx >> gy;
		cin >> n;
	
		for(int i=0;i<n;i++)
		{	
			int c,d,x,y;
			cin >> c >> d >> x >> y;
			g[y][x]=c;
			if(d==0)
			{
				g[y][x+1]=c;
				g[y][x+2]=c;
				g[y][x+3]=c;
				g[y+1][x]=c;
				g[y+1][x+1]=c;
				g[y+1][x+2]=c;
				g[y+1][x+3]=c;
				}
			else{
				g[y+1][x]=c;
				g[y+2][x]=c;
				g[y+3][x]=c;
				g[y][x+1]=c;
				g[y+1][x+1]=c;
				g[y+2][x+1]=c;
				g[y+3][x+1]=c;
				}
			}
	
	int p=g[sy][sx];
	if(p!=0)dfs(sy,sx,p);
	if(g[gy][gx]==-1){
		cout <<"OK" << endl;
		}
	else{
		cout << "NG" << endl;
		}
	}
	return 0;
	}

Measured memory_bytes: 1200
#include<iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int line[3];
  int x,y;
  for(int i=0; i < 3; ++i){
    cin >> line[i];
  }
  int max_index = max_element(line, line + 3) - line;

  if(max_index == 0){
    x = line[1];
    y = line[2];
  }else if(max_index == 1){
    x = line[0];
    y = line[2];
  }else{
    x = line[0];
    y = line[1];
  }

  cout << x*y/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
    int x;cin>>x;
    if(x==0)
    cout<<1<<endl;
    else
    cout<<0<<endl;
}

int32_t main() 
{
    rapido;
    int t;
    // cin>>t;
     t=1;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

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

		int rating = scan.nextInt();
		if(rating<1200) {
			System.out.println("ABC");
		}else if(rating<2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}




		scan.close();

	}
}


Measured memory_bytes: 21844
s = gets.chomp
k = gets.chomp.to_i
n = s.size
arr = []

s.split("").each do |e|
    arr << e
end

if arr.size == 1 then
    puts arr[0]
    exit
end

(n-1).times do |head|
    1.upto(k) do |tail|
        arr << s[head..(head + tail)]
    end
end
arr = arr.uniq.sort
puts arr[k-1]

Measured memory_bytes: 5500
#include<iostream>

using namespace std;

const int N(1009);
const int mod(1e9 + 7);

int n, m, ans;
int f[N][N];
char a[N][N];

int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	f[1][1] = 1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (i == 1 && j == 1) continue;
			if (a[i][j] == '.')
			{
				f[i][j] = (f[i - 1][j] + f[i][j - 1]) % mod;
			}
		}
	}
/*	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			cout<<f[i][j]<<' ';
		}
		cout<<endl;
	}*/
	cout<<f[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 5120
s=[i for i in list(input())]
t=True
for i in range(len(s)):
    if i %2==0:
        if s[i]=="L":
            t=False
            break
    else:
        if s[i]=="R":
            t=False
            break

if t:
    print("Yes")
else:print("No")

Measured memory_bytes: 3060
#include <stdio.h>

#define N_MAX 100

int
main(void)
{
	int i, j, u, k, n;
	int v[N_MAX];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &u, &k);
		for (j = 0; j < n; v[j++] = 0);
		for (j = 0; j < k; v[u-1] = 1, j++)
			scanf("%d", &u);
		for (j = 0; j < n; j++)
			printf("%s%d", j ? " " : "", v[j]);
		printf("\n");
	}


	return 0;
}



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

using namespace std;

struct P{
    string name;
    int time;
};

int main(){
    int n, q;
    scanf("%d %d", &n, &q);

    int head = 0;
    int tail = n;
    P p[100001];

    for(int i = 0; i < n; i++){
        cin >> p[i].name >> p[i].time;
    }

    int now = 0;

    while(head != tail){
        if(p[head].time <= q){
            now += p[head].time;
            cout << p[head].name << ' ' << now << '\n';
            head = (head + 1) % 100000;
        }
        else{
            p[head].time -= q;
            now += q;
            P tmp = p[head];
            head = (head + 1) % 100000;
            p[tail] = tmp;
            tail = (tail + 1) % 100000;
        }
    }
}


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

#ifndef __SOULTCH
#define endl '\n'
#define debug(...) 
#else
#define __debug_a(v) cout << " [+] " << #v << " = " << (v) << endl
#define __debug_b(v) cout << "     " << #v << " = " << (v) << endl
#define debug1(v1) __debug_a(v1);
#define debug2(v1, v2) __debug_a(v1), __debug_b(v2);
#define debug3(v1, v2, v3) __debug_a(v1), __debug_b(v2), __debug_b(v3);
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define debug(...) GET_MACRO(__VA_ARGS__, debug3, debug2, debug1)(__VA_ARGS__)
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << pai.first << ' ' << pai.second;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> s) {
    for (T p : s) cout << p << ' ';
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> s) {
    for (auto p : s) cout << '(' << p << ") ";
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int a[6];

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    rep(i, 6) cin >> a[i];
    if (a[4]-a[0] <= a[5]) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}








Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vi A(n);
    for(int i = 0; i < n; i++) cin >> A[i], A[i] *= 2;

    ll x = 0;
    for (int i = 0; i < n; i++) {
        x = A[i] - x;
    }
    x /= 2;

    for (int i = 0; i < n; i++) {
        cout << x << " ";
        x = A[i] - x;
    }
    cout << endl;

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    multiset<long long> s;
    long long a;
    rep(i, N){
        cin >> a;
        s.insert(a);
        set<long long>::iterator ite;;
        ite = s.find(a);
        while(ite != s.begin()){
            ite--;
            if(*ite < a){
                s.erase(ite);
                break;
            }
        }
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int sum = 0;
		int max = 0;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'I'){
				sum += 1;
			}
			else{
				sum -= 1;
			}
			max = Math.max(max, sum);
		}
		System.out.println(max);
	}

}


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

int main() {

    int n, m, x; cin >> n >> m >> x;

    int leftSum = 0;
    int rightSum = 0;
    for (int i = 0; i < m; i++) {
        int a; cin >> a;
        if (a < x) leftSum++;
        else rightSum++;
    }

    cout << min(leftSum,rightSum) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
//const ll MOD = 1000000007ll;
const ll MOD = 998244353ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    int n,m;
    std::cin >> n>>m;
    std::vector<int> a(n+1);
    rep(i,m){
        int t,tt;
        std::cin >> t>>tt;
        a[t]++;
        a[tt]++;
    }
    int b=1;
    rep(i,n+1){
        if(a[i]%2==1)b=0;
    }
    if(b)std::cout << YES << std::endl;
    else std::cout << NO << std::endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int a, b, c, d, e;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	int ans = 0;
	if(a < 0) {
		ans += abs(c * a);
		ans += d;
		a = 0;
	}
	ans += (b - a) * e;
	printf("%d\n", ans);
	return 0;
}

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

int	main()
{
  int	N;
  int	K;
  int	nb;
  
  cin >> N >> K;
  
  nb = 1;
  while (N-- > 0)
  {
    if (nb < K)
      nb *= 2;
    else
      nb += K;
  }
  cout << nb << endl;
  return (0);
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, count = 0, over = 0;
    bool kind[8];
    vector<int> vec;
    for (int i = 0; i < 8; ++i) {
        kind[i] = false;
    }

    cin >> N;
    vec.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> vec[i];
    }

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

    for (int i = 0; i < N; ++i) {
        int k = vec[i];
        if (1 <= k && k <= 399) kind[0] = true;
        if (400 <= k && k <= 799) kind[1] = true;
        if (800 <= k && k <= 1199) kind[2] = true;
        if (1200 <= k && k <= 1599) kind[3] = true;
        if (1600 <= k && k <= 1999) kind[4] = true;
        if (2000 <= k && k <= 2399) kind[5] = true;
        if (2400 <= k && k <= 2799) kind[6] = true;
        if (2800 <= k && k <= 3199) kind[7] = true;
        if (3200 <= k) ++over;
    }
    for (int j = 0; j < 8; ++j) {
        if (kind[j]) ++count;
    }
    if (count == 0) {
        cout << 1;
    } else {
        cout << count;
    }
    cout << " ";
    cout << count + over << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {

    int n, k;
    cin >> n >> k;

    int l = log(n)+1;

    vector<int> V;

    for (int i=0; i<k; i++) {
        int num;
        cin >> num;
        V.push_back(num);
    }

    bool var = true;

    while (true) {
        var = true;
        for (int i=0; i<k; i++){

            int nV = n;
            while (nV!=0){
                int dig;
                dig = nV%10;
                nV/=10;
                if (V[i]==dig){
                    var = false;
                    break;
                }
            }
        }

        if (var){
            cout << n << endl;
            break;
        } else {n++;}
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {

	Int L, R;
	cin >> L>>R;

	Int ans = INF;
	Int flag = 0;
	Int res = 0;
	for (Int i = L; i <= R; i++) {
		for (Int j = i+1; j <=R ; j++) {
			res = i * j % 2019;
			ans = min(ans, res);
			
			if (ans == 0) {
				cout << ans;
				return 0;
			}
		}
	}

	cout << ans << endl;

}

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

int main(){

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int b, e, t;
		cin >> b >>e >> t;
		swap_ranges(a.begin() + b, a.begin() + e, a.begin() + t);
	}
	for (int i = 0; i < n; i++) cout << (i == 0 ? "" : " ") << a[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 3116
class Array
  def cumsum; s = 0; map{|k| s += k } end
end

n, m = gets.to_s.split.map{|t|t.to_i}
a = Array.new(n){ gets.to_s.to_i }

if n == 1
  puts 1
  exit
end

if n == 2
  puts m == 1 ? 1 : 2
  exit
end

broken = Array.new(n+1){false}
stairs = Array.new(n+1){ 0 }
stairs[0] = stairs[1] = 1

a.each do |k|
  broken[k] = true
end

stairs[1] = 0 if broken[1]
# stairs[2] = 0 if broken[2]

2.upto(n) do |i|
  next if broken[i]
  stairs[i] = stairs[i-1] + stairs[i-2]
end

puts stairs[-1] % (10**9+7)

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

int64_t factorial( int64_t n ) {
	return n > 1 ? n*factorial( n-1 ) : n;
}

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	cout << factorial( n ) << endl;
}



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

int f(vector<int> &val){
    int Ans=0;
    for(int i=0; i<val.size();i++){
        Ans+=val[i]-1;
    }
    return Ans;
}

int main(void){
    int N;
    cin >> N;
    vector<int> a;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    cout << f(a);
    return 0;
}

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

typedef long long ll;

int N;
ll L[100010],R[100010];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%lld%lld",L + i,R + i);

    for(int i = 0; i < N; i++)R[i] *= -1;

    sort(L,L + N);
    reverse(L,L + N);
    sort(R,R + N);
    reverse(R,R + N);

    ll ans = 0,tmp = 0;
    for(int i = 0; i < N * 2; i++)
    {
        if(i % 2 == 0)tmp += L[i / 2];
        else tmp += R[i / 2];
        ans = max(ans,tmp);
    }

    tmp = 0;
    for(int i = 0; i < N * 2; i++)
    {
        if(i % 2 == 0)tmp += R[i / 2];
        else tmp += L[i / 2];
        ans = max(ans,tmp);
    }

    printf("%lld\n",ans * 2);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N; cin >> N;
	vector<int> a(N);
	vector<int> b(N);
	rep(i, N)cin >> a[i];
	int ans = 0;
	rep(i, N) {
		if (b[i] == 0 && i == a[a[i] - 1] - 1) {
			b[i] = 1;
			b[a[i] - 1] = 1;
			++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main () {
    int N, cnt=0;
    cin >> N;
    while (N>=0){
        if (N%4==0 || N==0){
            cnt++;
            break;
        }
        N-=7;
    }
    cnt ? cout << "Yes" : cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef int in;
#define int long long
 
in main() {
    int n,a[200005],mx = 0,cnt = 0,idx = 0;
    cin >> n;
    for(int i = 0 ; i < n ; i ++){
        cin >> a[i];
        mx = max(mx,a[i]);
    }
    for(int i = 0 ; i < n ; i ++){
        if(a[i] == mx){
            cnt ++;
            idx = i;
        }
    }
    sort(a,a + n);
    if(cnt > 1){
        for(int i = 0 ; i < n ; i ++){
            cout << mx << endl;
        }
    }
    else{
        for(int i = 0 ; i < n ; i ++){
            if(idx == i){
                cout << a[n - 2] << endl;
                continue;
            }
            cout << mx << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=1;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    int m=h.at(0);
    for(int i=1;i<n;i++){
        if(m<=h.at(i)){
            ans+=1;
            m=h.at(i);
        }
        else{
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    while (B <= A)
    {
        B *= 2;
        K--;
        if (K < 0)
        {
            break;
        }
    }
    while (C <= B)
    {
        C *= 2;
        K--;
        if (K < 0)
        {
            break;
        }
    }

    if (K < 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define N 3010
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
using namespace std;
int a[N];
bool win[N];
vector<int> g[N];
bool dfs(int x,int f){
	win[x]=0;
	for(auto to:g[x]){
		if(to!=f){
			dfs(to,x);
			if(a[x]>a[to] && !win[to]) return win[x]=1;
		}
	} return 0;
}
int main(){
	int n,u,v;
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,n-1){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	For(i,1,n) if(dfs(i,0)) printf("%d ",i);
} 


Measured memory_bytes: 640
n,m = map(int,input().split())
nm = [list(map(int,input().split())) for _ in range(m)]

cnt = [0] * n

for n,m in nm:
    cnt[n-1] += 1
    cnt[m-1] += 1

if all([i % 2 == 0 for i in cnt]):
    print('YES')
else:
    print('NO')


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  ll n, m;
  cin >> n >> m;
  ll ans;
  if(n==1&&m==1) {
    cout << 1 << endl;
    return 0;
  }
  if(n >= 2 && m >= 2) {
    ans = (n-2)*(m-2);
  }
  else {
    ans = n*m - 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256