akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    string s, ans = "Yes";
    cin >> s;
    REP(i, s.length()){
        if(i % 2 == 0){
            if(s[i] != 'h') ans = "No";
        } else {
            if(s[i] != 'i') ans = "No";
        }
    }

    if(s.length()%2 != 0) ans = "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
flag = 0
lst = [int(i) for i in input().split()][:n]
for i in lst:
    if i % 2 == 0 and i % 3 != 0 and i % 5 != 0:
        flag = 1
    else:
        continue
if flag == 1:
    print("DENIED")
else:
    print("APPROVED")

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	int h, w;
	cin >> h >> w;
	int r = -1;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			char c;
			cin >> c;
			cerr << i << " " << j << " " << r << endl;
			if(c == '#' && j < r) {
				cout << "Impossible" << endl;
				return 0;
			}
			if(c == '#') r = j;
		}
	}
	cout << "Possible" << endl;
	return 0;	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int X, Y, Z;
    int X_tmp, Y_tmp, Z_tmp;
    cin >> X >> Y >> Z;
    X_tmp = Y;
    Y_tmp = X;
    Z_tmp = X_tmp;
    X = Z;
    Y = Y_tmp;
    Z = Z_tmp;
    cout << X << " " << Y << " " << Z << " " << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;

	if (s == u) --a;
	if (t == u) --b;

	outt(a, b);

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

int main(){
    ll x,y,z;
    cin >> x >> y >> z;
    x-=y+2*z;
    ll d=y+z;
    ll ans=1+x/d;
    cout << ans << endl;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000


void Main() {
    ll s, w;

    cin >> s >> w;

    if (s <= w) {
        COUT("unsafe");
    }
    else {
        COUT("safe");
    }
} 

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



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

int main() {
    int A, B;
    cin >> A >> B;

    int ans = -1;
    if (A < 10 && B < 10) ans = A * B;

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


Measured memory_bytes: 256
n,m = map(int,input().split())
C = sorted(map(int,input().split()))


T = [float("inf")]*(n+1)
T[0]= 0

for i in range(m):
    for j in range(C[i],n+1):
        T[j] = min(T[j],T[j-C[i]]+1)

print(T[n])

Measured memory_bytes: 9504
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CHAndV solver = new CHAndV();
        solver.solve(1, in, out);
        out.close();
    }

    static class CHAndV {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int h = in.nextInt(), w = in.nextInt(), k = in.nextInt();

            int[][] grid = new int[h][w];
            for (int i = 0; i < h; i++) {
                char[] row = in.next().toCharArray();
                for (int j = 0; j < w; j++) {
                    grid[i][j] = row[j] == '#' ? 1 : 0;
                }
            }

            long answer = 0;

            for (int row = 0; row < (1 << h); row++) {
                for (int col = 0; col < (1 << w); col++) {
                    int count = 0;
                    for (int i = 0; i < h; i++) {
                        for (int j = 0; j < w; j++) {
                            if (((row >> i) & 1) == 0)
                                continue;
                            if (((col >> j) & 1) == 0)
                                continue;
                            count += grid[i][j];
                        }
                    }

                    if (count == k)
                        answer++;
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for(int i = L; i <= R; i++) {
        if(i % d == 0) {
            ans++;
        }
    }

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


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vp = vector<pii>;
using vs = vector<string>;
using qi = queue<int>;
using qp = queue<pii>;
using pqi = priority_queue<int>;
using pqim = priority_queue<pii, vector<pii>, greater<pii> >;
using ppp = pair<int, pair<int, int>>;
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define pb push_back
const ll mod = 998244353;
const ll inf = 1e18;

int n;
vi a;

void input() {
	cin >> n;
	a = vi(n + 1);
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
}

void solve() {

	sort(a.begin(), a.end());
	int mx = a.back();

	map<int, int> pos;
	for (int i = 1; i <= n; ++i) {
		if (pos[a[i]]) continue;
		pos[a[i]] = i;
	}

	vi res(n + 1);

	for (int i = 1; i <= n; ++i) {
		if (a[i] == a[i - 1]) res[i - 1] = res[i] = 2;
		if (res[i]) continue;
		for (int j = 2; a[i] * j <= mx; ++j) {
			auto t = pos.find(a[i] * j);
			if (t == pos.end()) continue;
			res[(*t).second] = 2;
		}
		res[i] = 1;
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i)
		if (res[i] == 1)
			ans++;

	cout << ans;

	return;
}

int main() {
	cin.tie(NULL); ios_base::sync_with_stdio(false);

	input();
	solve();
}

Measured memory_bytes: 14256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()

    ret = 0
    for n in range(int(N ** 0.5) + 1):
        if n * n <= N:
            ret = max(ret, n * n)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10396
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    c = collections.Counter()

    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                if x * x + y * y + z * z + x * y + y * z + z * x >= 10001:
                    continue
                c[x * x + y * y + z * z + x * y + y * z + z * x] += 1

    for i in range(1, N + 1):
        print(c[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 10100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int a, b, c, x, ans=0;
    cin >> a >> b >> c >> x;
    rep(i,a+1) rep(j,b+1) rep(k,c+1) if (500*i+100*j+50*k == x) ans++;
    cout << ans << endl;
}


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

signed main() {
  int N;
  cin >> N;
  vector<int> B(N);
  for(int i=0; i<N-1; i++) cin >> B[i];

  int ans = B[0] + B[N-2];
  for(int i=1; i<N-1; i++) {
    cerr << i << " " << min(B[i],B[i-1]) << " " << B[i] <<" " << B[i-1]<< endl;;
    ans += min(B[i],B[i-1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	string s; cin >> s;
	for (int i = 0; i < (int)s.size(); i++) {
		cout << (char)(((s[i] - 'A') + n) % 26 + 'A');
	}
	cout << endl;
	return 0;
}

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

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

int main(int argc, char** argv) {
    int n, m, prev;

    cin >> n >> m;
    vector<int> ac(n), wa(n);

    prev = 0;
    rep(i, m) {
        int d;
        string ans;
        cin >> d >> ans;

        if (ac[d - 1])
            continue;
        if (ans == "AC")
            ac[d - 1] = 1;
        else
            wa[d - 1]++;
    }

    ll sumac = 0;
    ll sump = 0;
    rep(i, n) {
        if (ac[i] > 0) {
            sumac += ac[i];
            sump += wa[i];
        }
    }
    cout << sumac << " " << sump << endl;
    return 0;
}

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

using namespace std;

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

    string S; cin>>S;
    char pc = S.back();
    long nbc = 0;
    long ans = 0;
    for (int i = S.size()-2; i >= 0; i--) {
        auto c = S[i];
        if (c == 'B') {
            if (pc == 'C')
                nbc++;
            else
                nbc = 0;
        } else if (c == 'C') {
            if (pc == 'C')
                nbc = 0;
        } else if (c == 'A') {
            if (pc == 'C')
                nbc = 0;
            ans += nbc;
        }
        pc = c;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 720
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int n,k;cin>>n>>k;
    vector<ll> a(n);
    rep(i, n) {
        cin>>a[i];
    }
    dump(a);

    rep(i, k, n){
        if (a[i] <= a[i-k]) {
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 4760
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int h,w,k,n,i,ii,j,jj,m,mm,co,res=1010;
  int t[10],c[10][1000];
  bool f;
  vector<int> v;
  string s;
  cin >> h >> w >> k;
  for(i=0;i<h;i++){
    cin >> s;
    for(j=0;j<w;j++)
      c[i][j]=stoi(s.substr(j,1));
  }
  n=1<<(h-1);
  for(i=0;i<n;i++){
    v.clear();
    ii=i;
//    cout << i << " ";
    for(j=0;j<h-1;j++){
      if(ii%2==1){
        v.push_back(j);
//        cout << j << " ";
      }
      ii>>=1;
    }
    v.push_back(h-1);
//    cout << h-1 << endl;
    fill(t,t+10,0);
    co=v.size()-1;
    f=0;
    for(j=0,jj=0;j<w;j++){
      for(m=0,mm=0;m<v.size();m++)
        for(;mm<=v[m];mm++)
          t[m]+=c[mm][j];
      for(m=0;m<v.size();m++)
        if(t[m]>k){
          if(j==jj){
            f=1;
            break;
          }
          co++;
          fill(t,t+10,0);
          jj=j;
          j--;
          break;
        }
      if(f==1) break;
    }
    if(f==0){
      res=min(res,co);
//      cout << i << " " << res << endl;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;
const long long int INF = 99999999999999999;


int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	string str;
	long long int n, m, res = 0, cou = 0;
	cin >>str;
	if (str[0]==str[1]|| str[2] == str[1]|| str[2] == str[3]) {
		cout << "Bad";
	}
	else {
		cout << "Good";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 3e3+7;
const ll INF = 1e18;

ll n;
double dp[nax][nax],p[nax];

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin>>n;
	
	for (ll i=0;i<n;++i) cin>>p[i];
	
	dp[0][0]=1;
	for (ll i=0;i<n;++i){
		for (ll j=0;j<=n;++j){
			dp[i+1][j] += dp[i][j]*(1-p[i]);
			dp[i+1][j+1] += dp[i][j]*p[i];
		}
	}
	
	/*for (ll i=1;i<=n;++i){
		for (ll j=0;j<=n;++j) cout<<dp[i][j]<<" ";
		cout<<"\n";
	}*/
	
	double res=0;
	
	for (ll i=(n+1)/2;i<=n;++i) res+=dp[n][i];
	
	cout<<setprecision(10)<<res<<"\n";
}

Measured memory_bytes: 74224
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if (a != b && b != c && c != a) {
      System.out.println(3);
    } else if (a == b && b == c && c == a) {
      System.out.println(1);
    } else {
      System.out.println(2);
    }
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=998244353;
const ll mod=998244353;
signed main(){
    char a;cin>>a;
    if(a-'a'>=0&&a-'a'<26){
        cout<<'a'<<endl;
    }else{
        cout<<'A'<<endl;
    }
}

Measured memory_bytes: 3628
// D - Menagerie

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

char same(char c) {
	return c;
}

char diff(char c) {
	if (c == 'S') return 'W';
	else return 'S';
}

void align(char first, char second, string& s, string& ans, int N) {
	ans[0] = first;
	ans[1] = second;
	for (int i=1; i<N-1; i++) {
		if (ans[i] == 'S') {
			if (s[i] == 'o') ans[i+1] = same(ans[i-1]);
			else ans[i+1] = diff(ans[i-1]);
		} else {
			if (s[i] == 'o') ans[i+1] = diff(ans[i-1]);
			else ans[i+1] = same(ans[i-1]);
		}
	}
}

bool verify(string& s, string& ans, int N) {
	if (ans[0] == 'S') {
		if (s[0] == 'o') {
			if (ans[N-1] != ans[1]) return false;
		} else {
			if (ans[N-1] == ans[1]) return false;
		}
	} else {
		if (s[0] == 'o') {
			if (ans[N-1] == ans[1]) return false;
		} else {
			if (ans[N-1] != ans[1]) return false;
		}
	}

	if (ans[N-1] == 'S') {
		if (s[N-1] == 'o') {
			if (ans[N-2] != ans[0]) return false;
		} else {
			if (ans[N-2] == ans[0]) return false;
		}
	} else {
		if (s[N-1] == 'o') {
			if (ans[N-2] == ans[0]) return false;
		} else {
			if (ans[N-2] != ans[0]) return false;
		}
	}

	return true;
}

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

	string s;
	cin >> s;

	string ans;
	ans.resize(N, ' ');

	// 1番目の動物が羊、2番目も羊と仮定
	align('S', 'S', s, ans, N);
	if (verify(s, ans, N)) {
		cout << ans << endl;
		return 0;
	}

	// 1番目の動物が羊、2番目は狼と仮定
	align('S', 'W', s, ans, N);
	if (verify(s, ans, N)) {
		cout << ans << endl;
		return 0;
	}

	// 1番目の動物が狼、2番目は羊と仮定
	align('W', 'S', s, ans, N);
	if (verify(s, ans, N)) {
		cout << ans << endl;
		return 0;
	}

	// 1番目の動物が狼、2番目も狼と仮定
	align('W', 'W', s, ans, N);
	if (verify(s, ans, N)) {
		cout << ans << endl;
		return 0;
	}

	// 全て矛盾
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main()
{
	int a[5],j;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	
	for(int i=1;i<5;i++){
		if(a[0]<a[i]){
			j=a[0];
			a[0]=a[i];
			a[i]=j;
		}
	}
	for(int k=2;k<5;k++){
		if(a[1]<a[k]){
			j=a[1];
			a[1]=a[k];
			a[k]=j;
		}
	}
	for(int l=3;l<5;l++){
		if(a[2]<a[l]){
			j=a[2];
			a[2]=a[l];
			a[l]=j;
		}
	}
	if(a[3]<a[4]){
		j=a[3];
		a[3]=a[4];
		a[4]=j;
	}
	
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<endl;
		
	return 0;
}           

Measured memory_bytes: 3100
n = int(input())
a = [0]
a.extend(list(map(int,input().split())))
a.append(0)

cost = []

for i in range(n):
  cost.append(abs(a[i+1]-a[i]))
cost.append(abs(a[-2]))

s_cost = sum(cost)
for i in range(n):
  print(s_cost - cost[i]- cost[i+1] + abs(a[i+2]-a[i]))

Measured memory_bytes: 14048
using System;

namespace ABC079_C_Train_Ticket
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string input = Console.ReadLine();
			int a = int.Parse(input.Substring(0, 1));
			int b = int.Parse(input.Substring(1, 1));
			int c = int.Parse(input.Substring(2, 1));
			int d = int.Parse(input.Substring(3, 1));

			if (b + c + d == 7 - a)
			{
				Console.WriteLine(a + "+" + b + "+" + c + "+" + d + "=" + 7);
			}else if (- b + c + d == 7 - a)
			{
				Console.WriteLine(a + "-" + b + "+" + c + "+" + d + "=" + 7);
			}else if (- b - c + d == 7 - a)
			{
				Console.WriteLine(a + "-" + b + "-" + c + "+" + d + "=" + 7);
			}else if (- b - c - d == 7 - a)
			{
				Console.WriteLine(a + "-" + b + "-" + c + "-" + d + "=" + 7);
			}else if (- b + c - d == 7 - a)
			{
				Console.WriteLine(a + "-" + b + "+" + c + "-" + d + "=" + 7);
			}else if (b - c + d == 7 - a)
			{
				Console.WriteLine(a + "+" + b + "-" + c + "+" + d + "=" + 7);
			}else if (b - c - d == 7 - a)
			{
				Console.WriteLine(a + "+" + b + "-" + c + "-" + d + "=" + 7);
			}else if (b + c - d == 7 - a)
			{
				Console.WriteLine(a + "+" + b + "+" + c + "-" + d + "=" + 7);
			}
		}
	}
}

Measured memory_bytes: 13140
def solve():
    N, A, B, C, D = map(int, input().split())

    H = abs(A - B)

    if D == 0:
        return (H == 0)

    mi = C * (N - 1)
    ma = D * (N - 1)

    if H > ma:
        return False

    return ((H - mi) % (C + D) <= (ma - mi))

if solve():
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int h, w;
    cin >> h >> w;
    vstr a(h);
    rep(i, h) cin >> a[i];

    vvll dp(h+1, vll(w+1, 0));
    dp[1][1] = 1;
    rep(i, h) rep(j, w) {
        if (i == 0 && j == 0) continue;
        if (a[i][j] == '#') {
            dp[i+1][j+1] = 0;
            continue;
        }
        dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1])%MOD;
    }

    // rep(i, h+1) show_ary(dp[i]);
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define fi first
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
 
int32_t main() 
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	fastIO;
	ll t,n,i,j,a,c,d,k,q,l,r,x,y;
	cin>>t;
	ll cnt=0;
	ll maxi=0;
	while(t--)
	{
		cin>>a>>c;
		if(a==c)
		{
			cnt++;
			maxi=max(maxi,cnt);
		}
		
		else
		{
			
			cnt=0;
		}
		
	}
	if(maxi>=3)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
	return 0;
}

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

int main(){
	int a,b,d,r;
	double f;
	cin>>a>>b;
	std::cout<<std::fixed;
	std::cout<<a/b<<" "<<a%b<<" "<<std::setprecision(5)<<1.0*a/b<<endl;	
return 0;
}


Measured memory_bytes: 3256
n = int(input())
a = list(map(int, input().split()))

flag = 0
count = 0

while True:
    for i in range(len(a)):
        if a[i] % 2 == 1:
            flag = 1
            break
        else:
            a[i] = a[i] //2
    
    if flag == 1:
        break

    count += 1


print(count)


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

int main(){
    int N;
    cin>>N;
    int answer=0;
    vector<vector<int>> ans={
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0},
    };
    for(int i=1;i<=N;i++){
        int m=i%10;
        if(m>0){
        int M=1;
        if(i>99999){
            M=100000;
        }
        else if(i>9999){
            M=10000;
        }
        else if(i>999){
            M=1000;
        }
        else if(i>99){
            M=100;
        }
        else if(i>9){
            M=10;
        }
        int mm=i/M;
        if(mm>0){
        ans.at(m-1).at(mm-1)++;
    }}}

    for(int i=0;i<9;i++){
        for(int j=0;j<=i;j++){
            if(i==j){
                answer+=ans.at(i).at(j)*ans.at(j).at(i);
            }
            else{
                answer+=ans.at(i).at(j)*ans.at(j).at(i)*2;
            }
        }
    
    }
    cout<<answer<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

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

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
 
int main() {
    int a, b,c;
    cin >> a >> b >> c;
     bool x = false;
     if(a-b == 0){
       if(a-c != 0){
         x = true;
       }
     }else if(a-c == 0||b-c== 0){
       x = true;
     }
  if(x == true){
    cout << "Yes" << endl;
}else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
C = tuple(map(int,input().split()))
B = list(map(int,input().split()))
A = list(C)
for i in range(N)[::-1]:
    if A[i+1] > B[i]:
        A[i+1] -= B[i]
    elif B[i] < A[i]+A[i+1]:
        A[i] -= (B[i] - A[i+1])
        A[i+1] = 0
    else:
        A[i] = 0
        A[i+1] = 0
ans = 0
for j in range(N+1):
    ans += C[j]-A[j]
print(ans)

Measured memory_bytes: 25476
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] h = nextIntArray(sc, N);

		sc.close();

		int ans = 0;
		for (int i = 0; i < N; i++) {
			if (h[i] >= K) {
				ans++;
			}
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 51516
#include<stdio.h>
int main( )
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x + r<= W && x-r>=0)&&(y+r<=H&&y-r>=0))
	{
		printf("Yes\n");
	}
	else
	{
	    printf("No\n");	
    }
    return 0;
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


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


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

//#define int long long //change int main to int32_t main


void solve()
{
	int n; cin >> n;
	int dp[n + 5][3];
	cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
	fr(i, 1, n)
	{
		int a, b, c;
		cin >> a >> b >> c;
		dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b + max(dp[i - 1][2], dp[i - 1][0]);
		dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << nl;

}





int main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 4824
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getIntArray :: IO [Int]
getIntArray = ((map (\a -> read a :: Int)) . words) <$> getLine

getStrArray :: Int -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

isGood :: String -> String
isGood [a, b, c, d] 
    | a == b && b == c = "Yes"
    | b == c && c == d = "Yes"
    | otherwise = "No"

main = do
    print =<< (\a -> 24 + (24 - a)) <$> getInt


Measured memory_bytes: 508
var n, m;
var x = [];

function main(){
	n = scan();
	m = scan();
	rep(n, function(i){
		x[i] = 0;
	});
	rep(m, function(i){
		var c = scan();
		var d = scan();
		x[c] += 1;
		x[d] -= 1;
	});
	rep(1, n, function(i){
		x[i] += x[i - 1];
	});
	var c = 0;
	rep(n, function(i){
		if(x[i] > 0){
			++c;
		}
	});
	print(c * 2 + n + 1);
}

function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}

var input = '';

function scan(){
	return +input.pop();
}
function scan_string(){
	return input.pop();
} 
function print(val){
	console.log(val);
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/).reverse();
	main();
});

Measured memory_bytes: 16160
#include<bits/stdc++.h>
// #include <boost/math/common_factor.hpp> 
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
#define F first
#define S second
//#define tr(container, it) \
//for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
const int N=1e6+5;
int mod = 1e9+7;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
ll pow1(ll n,ll p)
{
    if(p==0)    return 1;
    ll x=pow1(n, p/2);
    x=(x*x)%mod;
    if(p%2==0)
        return x;
    else
        return (x*n)%mod;
}
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
}
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
    if(p1.F < p2.F) return true;
        if(p1.F == p2.F) return p1.S < p2.S;
        return false;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int32_t main()
{
    IOS;

    int n;
    cin>>n;
    vector<vector<int>>a(n+1,vector<int>(3)); 
    vector<vector<int>>dp(n+1,vector<int>(3));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
            if(i==0)dp[i][j] = a[i][j];
    }
}

    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
                }
            }
        }
    }    
    int mx = 0;
    for(int i=0;i<3;i++)mx = max(mx,dp[n-1][i]);
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 11264
import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix

n, x, y = map(int, input().split())

v = [x-1]
u = [y-1]
for i in range(n-1):
    v.append(i)
    u.append(i+1)

csr = csr_matrix(([1]*n, (v, u)), shape=(n, n))
result = shortest_path(csr, method='D', directed=False).astype(int)
ans = np.bincount(result.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')

Measured memory_bytes: 76484
//                                ** ALLAH **
//                        who is Hussain? -> whoishussain.org

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007;
inline int in(){ int x; scanf("%d",&x); return x; }
const int N = 1e5 + 100;
int s[2][N][2], q;
int ans[3][3];
int get(int l, int r, int t){
        return ans[ (s[t][r][0] - s[t][l][0]) % 3][ (s[t][r][1] - s[t][l][1]) % 3  ]; 
}
int32_t main(){
        ans[1][1] = ans[2][2] = ans[0][0] = 3;
        ans[1][2] = 2;
        ans[2][1] = 1;
        ans[1][0] = 1;
        ans[2][0] = 2;
        ans[0][1] = 2;
        ans[0][2] = 1;
        ios::sync_with_stdio(false), cin.tie(0);
        string ss[2];
        cin >> ss[0] >> ss[1];
        for(int t = 0; t < 2; t++){
                for(int i = 1; i <= ss[t].size(); i++){
                        for(int k = 0; k < 2; k++)
                                s[t][i][k] = s[t][i-1][k]; 
                        s[t][i][ss[t][i-1]-'A']++;
                }
        }
        cin >> q;
        while( q-- ){
                int l1,l2,r1,r2;
                cin >> l1 >> r1 >> l2 >> r2;
                l1--,l2--;
                if( get( l1,r1, 0) == get( l2, r2, 1 ) )
                        cout << "YES"<< '\n';
                else cout << "NO" << '\n';
        }
}


Measured memory_bytes: 2512
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e5+5;
int A[maxn], N,H;

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    while (cin >> N >> H) {
        int maxa = 0;
        FOR(i,0,N) {
            int a,b; cin >> a >> b;
            A[i] = b;
            maxa = max(maxa,a);
        }
        sort(A,A+N); reverse(A,A+N);
        int i = 0;
        for (; i < N; i++)
            if (A[i] < maxa)
                break;
        int ans = 0;
        FOR(j,0,i) if (H > 0) {
            H -= A[j]; ans++;
        }
        if (H > 0)
            ans += ceil(1.0*H/maxa);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int sum=0;
    for(int j=0; j<n-1; j++)
    {
        if(a[j]==a[j+1])
       a[j]=0,a[j+1]=0;
    }
    for(int k=0;k<n;k++)
    {
        if(a[k]!=0)
            sum++;
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100000001
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[100];
ll dp[100][21];
int main(){
	int n;
	scanf("%d", &n);
	rep(i,n)scanf("%d", &a[i]);
	dp[0][a[0]] = 1;
	for(int i = 1;i < n-1;i++){
		for(int j = 0;j <= 20;j++){
			if(j+a[i] <= 20)dp[i][j+a[i]] += dp[i-1][j];
			if(j-a[i] >= 0)dp[i][j-a[i]] += dp[i-1][j];
		}
	}
	printf("%lld\n", dp[n-2][a[n-1]]);
	return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int n,num[1000005],prev1[100005],prev2[100005],maxv;
inline int gcd(int a,int b)
{
	if (!b)
	{
		return a;
	}
	else
	{
		gcd(b,a%b);
	}
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i) cin>>num[i];
//	cout<<gcd(4,6)<<endl;
	prev1[1]=num[1];prev2[n]=num[n];
	for (int i=2;i<=n;++i)
	{
		prev1[i]=gcd(num[i],prev1[i-1]);
	} 
	for (int i=n-1;i>=1;--i)
	{
		prev2[i]=gcd(num[i],prev2[i+1]);
	}
//	for (int i=1;i<=n;++i) cout<<prev1[i]<<' '<<prev2[i]<<endl;
	for (int i=1;i<=n;++i)
	{
		if (i!=1&&i!=n)
			maxv=max(maxv,gcd(prev1[i-1],prev2[i+1]));
		else if (i==1)
		{
			maxv=max(maxv,prev2[i+1]);
		}
		else
		{
			maxv=max(maxv,prev1[i-1]);
		}
	}
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define S size()
#define E end()
#define B begin()
#define L length()
 
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define fl float
#define ld long double
#define ll long long

#define gcd __gcd
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define all(v) v.B,v.E
#define acc(v) accumulate(all(v), 0)
#define psum partial_sum
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation
#define maxe *max_element
#define mine *min_element
 
#define forl(i,n) for(ll i = 0; i < n; i++)
#define fore(i,m,n) for (ll i = m; i <= n; i++)
#define rforl(i,n) for (ll i = n - 1; i >= 0; i--)
#define rfore(i,m,n) for (ll i = m; i >=n; i--)    
#define iter(s) for(auto it:s)
 

#define prec(n) fixed<<setprecision(n)
#define popcnt(n) __builtin_popcountll(n)
#define parity(n) __builtin_parityll(n)
#define clz(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctzll(n)

#define sll set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vll vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define msll multiset<ll>
#define msc multiset<char>
#define vvll vector<vector<ll>>
#define rev reverse

#define tc ll q;cin>>q;while(q--)
#define pat ll n;cin>>n
#define pat1 vll a(n);forl(i,n)cin>>a[i]
#define pat2 ll n,k;cin>>n>>k;vll a;forl(i,n) cin>>a[i]
#define pats string s;cin>>s
#define yesno if(flag)cout<<"YES\n";else cout<<"NO\n"
#define loop forl(i,n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a,b) cout << a << " " << b << endl
#define p3(a,b,c) cout << a << " " << b << " " << c << endl
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl
 
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832
//**********************************
 
int main(){
    
    pat;
    pat1;
    ll ans=0;
    sort(all(a));
    fore(i,0,n-1){
        fore(j,i+1,n-1){
            fore(k,j+1,n-1){
                if(a[i]!=a[j] && a[j]!=a[k]){
                    if(a[i]+a[j]>a[k]){
                        ans++;
                    }
                }
            }
        }
    }
    p1(ans);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e6 + 10;
const int MOD = 1e9 + 7;
char s[100];
int main() {
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0;i<len-8;i++) printf("%c",s[i]);
    puts("");
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    string word;
    for (int i=0; i<n; i++) {
        cin >> word;
        if (word == "AC") {
            ac++;
        } else if (word == "WA") {
            wa++;
        } else if (word == "TLE") {
            tle++;
        } else if (word == "RE") {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        long ans = 0;
        if(a+b>=k){ans=Math.min(a,k);}
        else{ans=a-(k-a-b);}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35760
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int N, K;
	cin >> N >> K;
	int H;
	int R = 0;
	for (int i = 0; i < N; i++) {
		cin >> H;
		if (H >= K)R++;
	}
	cout << R << endl;
	return 0;
}


Measured memory_bytes: 256