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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

pii solve(const vi& a) {
    int n = a.size();
    vi p(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        p[i + 1] = p[i] + a[i];
    }

    /*
    for (int x : p) {
        cout << x << ' ';
    }
    cout << '\n';
    */

    // 2 * p[i] - 2 * p[j] >= i - j
    // 2 * p[i] - i >= 2 * p[j] - j
    int j = 0;
    for (int i = 1; i <= n; ++i) {
        if (i - j >= 2 and 2 * p[i] - 2 * p[j] > i - j) {
            // cout << "2 * " << p[i] << " - 2 * " << p[j] << " > " << i - j << '\n';
            return {j + 1, i};
        }

        if (2 * p[i - 1] - (i - 1) < 2 * p[j] - j) {
            // cout << "changing j to " << (i - 1) << " with val " << 2 * p[i - 1] - (i - 1) << '\n';
            j = i - 1;
        }
    }

    return {-1, -1};
}

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

    string s;
    cin >> s;

    int n = s.size();
    vi a(n);
    for (int k = 0; k < 26; ++k) {
        for (int i = 0; i < n; ++i) {
            a[i] = (s[i] == (k + 'a'));
        }

        pii res = solve(a);
        if (res.first != -1) {
            cout << res.first << ' ' << res.second << '\n';
            return 0;
        }
    }

    cout << "-1 -1\n";
    
    return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
void fastio()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

}
vector<ll int > v[200005];
ll int vis[200005]={0};

ll int dfs(ll int x)
{
	ll int ans=0;
	if (vis[x]==0)
	{
		vis[x]=1;
		ans++;

	for(auto i: v[x])
	{
		
		ans+=dfs(i);

	}
    }
    return ans;
}

 int main()


{
	fastio();
	ll int n,m;
	cin>>n>>m;
	ll int i;
	
	set<pair<ll int, ll int > > s;
	for(i=0;i<m;i++)
	{
		ll int x,y;
		cin>>x>>y;
		if (y<x)
			swap(x,y);
		s.insert(mp(x,y));

	}
	for(auto i: s)
	{
		v[i.first].pb(i.second);
		v[i.second].pb(i.first);
	}
	ll int ans=0;
	
	for(i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
		ll  int l=dfs(i);
		ans=max(ans,l);
	    }
	}
	cout<<ans<<endl;	

	
	
}



	
  
  

		
		
		
		
		
		
	
	
	 
		
		
	
	
	

	


	
	
	
   



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

using namespace std;

typedef long long ll;

int main(){
        ll N, A, B;
        ll lb=0, rb=1e10;
        cin>>N>>A>>B;
        vector <ll> h;
        for(ll i=0;i<N;i++){
                ll hh;
                cin>>hh;
                h.push_back(hh);
        }
        ll C=A-B;
        while(rb-lb>1){
                //cout<<lb<<" "<<rb<<endl;
                ll k=(rb+lb)/2;
                ll cnt=0;
                for(int i=0;i<N;i++){
                        ll hh=h[i]-k*B;
                        //cout<<hh<<endl;
                        if(hh>0){
                                cnt+=(hh/C);
                                if(hh%C){
                                        cnt++;
                                }
                        }
                }
                if(cnt<=k){
                        rb=k;
                }
                else{
                        lb=k;
                }
        }
        cout<<rb<<endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
  
}

Measured memory_bytes: 3588
S = input()


def is_palindrome(s):
  s_rev = ''.join(reversed(s))
  return s == s_rev

halfS = len(S) // 2
if is_palindrome(S) and \
  is_palindrome(S[:halfS]) and \
  is_palindrome(S[1+halfS:]):
    print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
b = list(map(int, input().split()))
def fac(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

la=fac(b[0])
lb=fac(b[1])


print(len(set(la) & set(lb))+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main()
{
  int n,x[10],y[10];
  long long int m=0;
  cin>>n;
  vector<int> c;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    c.push_back(i);
  }
  double sum=0;
  do{
    for(int i=0;i<n-1;i++){
      sum+=fabs(sqrt(pow(x[c[i]]-x[c[i+1]],2)+pow(y[c[i]]-y[c[i+1]],2)));
    }
    m++;
  }while(next_permutation(c.begin(),c.end()));
  sum/=m;
  printf("%f\n",sum);
  return 0;
}

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

int u[105];

int p(int x){
    if(x == u[x])return x;
    return u[x] = p(u[x]);
}

void unin(int a, int b){
    a = p(a);
    b = p(b);
    u[a] = b;
}

int main(){
    int n, in[105], out[105];
    string str;
    while(cin >> n, n){
	for(int i = 0;i < 26;i++){
	    in[i] = out[i] = 0;
	    u[i] = i;
	}
	int c;
	for(int i = 0;i < n;i++){
	    cin >> str;
	    c = str[0];
	    in[str[0] - 'a']++;
	    out[str[str.size() - 1] - 'a']++;
	    unin(str[0] - 'a', str[str.size() - 1] - 'a');
	}
	bool ok = true;
	for(int i = 0;i < 26;i++){
	    if(in[i] != out[i])ok = false;
	    if(in[i] && p(c - 'a') != p(i))ok = false;
	}
	if(ok)cout << "OK" << endl;
	else cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

// GCD, LCM
// https://youtu.be/8lm8o8L9Bmw?t=2285
// https://youtu.be/XI8exXVxZ-Q?t=3595
// https://youtu.be/F2p_e6iKxnk?t=843
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;}

int f(ll p){
    int res = 0;
    while(p%2==0){
        p/=2;
        res++;
    }
    return res;
}

int main(){
    int n,m;
    cin >> n >> m;
    ll a[100010],b[100010];
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        b[i]=a[i]/2;
    }
    ll temp=b[0];
    int t=f(temp);

    rep(i,n-1){
        if(f(b[i+1])!=t){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,n){
        rep(j,t){
            b[i]/=2;
        }
    }
    rep(j,t){
        m/=2;
    }
    ll blc=b[0];
    rep(i,n-1){
        blc=lcm(blc,b[i+1]);
    }
    

    ll x=(m/blc+1)/2;
    cout << x<< endl; 
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	string s;
	ll total=0;

	cin>>s;
	ll o=0;

	for(ll i=0; i<s.size()+1; i++){
		if(s[i]=='W'){
			o++;
			total+=(i+1)-o;
		}
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.io.*;
 
public class Main {
 
    private static int count;
 
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while (null != (str = in.readLine())) {// 入力の終わりまで
            doit(Integer.parseInt(str));
        }
    }
 
    private static void doit(int n) {
        count = (n>=2)?1:0;
         
        for (int i = 3; i <= n; i+=2)
            if (isPrime(i))count++;
         
        System.out.println(count);
    }
 
    private static boolean isPrime(int n) {// 素数判定メソッド
        if (n < 2)
            return false;
        else if (n == 2)
            return true;
 
        if (n % 2 == 0)
            return false;
 
        for (int i = 3; i <= n / i; i += 2)
            if (n % i == 0)
                return false;
        return true;
    }
}

Measured memory_bytes: 16900
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N,K;
int A[200000];

int main(){
    cin>>N>>K;
    rep(i,N) cin>>A[i];

    for(int i=K;i<N;i++){
        if(A[i-K]<A[i]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M;
int A[110000], B[110000];
vint G[110000], rev[110000];
bool visited[110000];
vint sorted;

void dfs(int x) {
    if (visited[x]) { return; }
    visited[x] = true;
    rep(i, G[x].size()) { dfs(G[x][i]); }
    sorted.push_back(x);
}

signed main() {
    cin >> N >> M;
    reps(i, N - 1 + M) {
        cin >> A[i] >> B[i];
        G[A[i]].push_back(B[i]);
        rev[B[i]].push_back(A[i]);
    }
    reps(i, N) { dfs(i); }
    reverse(all(sorted));
    map<int, int> mp;
    rep(i, N) { mp[sorted[i]] = i + 1; }
    reps(i, N) {
        int ans = 0;
        rep(j, rev[i].size()) {
            if (mp[ans] < mp[rev[i][j]]) { ans = rev[i][j]; }
        }
        cout << ans << endl;
    }

}

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

#define eb emplace_back
#define pb push_back
#define INF 1LL<<62
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<int, int>;
using int3 = tuple<ll, ll, ll>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C> string to_string(const tuple<A, B, C>& p) {
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) +  ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T mul_mod(T a, T b, T mod) {
  T res = 0;
  a %= mod;
  while (b) {
    if (b & 1) {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
*/

class mytask {
public:
  mytask() { }

  int solve() {

    ll a, b;
    cin >> a >> b;

    if ((a + b) % 2 == 0) {
      cout << (a + b) / 2;
    } else {
      cout << "IMPOSSIBLE";
    }



    return 0;
  }
};


int main() {

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

  auto task = mytask();
  task.solve();

  cout << endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    int n;cin>>n;
    int a[333];
    for(int i = 0;i < n;i++) {
        cin>>a[i];
    }
    int cnt = 0;
    while(true) {
        bool flg = false;
        for(int i = 0;i < n;i++) {
            if(a[i]%2 == 0) {
                a[i] /= 2;
            } else {
                flg = true;
                break;

            }
        }
        if(flg) break;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#define LOCAL
#include <iostream>
#include <map>
#include <iterator>
#include <bits/stdc++.h>
#include <stdbool.h>
#include <math.h>
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define show(x)     cout << (#x) << ":" << x << endl;
#define show2(x,y)  cout << (#x) << ":" << x << " " << (#y) << ":" << y << endl;
#define ll long long
#define ld long double
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,a,b) for(int (i)=(a);(i) < (b); (i)++)
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V){os << "[ "; for(auto v  : V) os << v << " "; return os << "]";}
template<class T> ostream& operator<<(ostream &os, set<T> V){os << "[ "; for(auto v  : V) os << v << " "; return os << "]";}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){os << "[ "; for(auto v  : V) os << "(" << v.first << ":" << v.second << ")"; return os << "]";}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){return os << "(" << V.first << "," << V.second << ")";}
 
#define cerr cout
#ifdef LOCAL
    #define TRACE
#endif
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << "T->";cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){cerr << "T->";const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...);}
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<"\n"
#define d2(x,y) cout<<(x)<<" "<<(y)<<"\n"
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<"\n"
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<"\n"
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<"\n"
#define print(a) for(auto x:a) cout<<x<<" "; cout<<"\n"; 
// Use max({a,b,c,d,....}) instead
// #define max3(a,b,c) max(max((a),(b)),(c))
// #define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
void solve(){
	int n;
	cin>>n;
	int x=n;
	int c=0;
	while(true){
		if(x%1000==0){
			break;
		}
		c++;
		x++;
	}
	cout<<c<<endl;
}

int main() {
    io();
   //int t;
   // cin >> t;
    //rep(i,0,t){
        solve();
    //}
    return 0;
}

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

int main(){
  int n; cin >> n;
  double ans = 0;
  for(int i = 0; i < n; i++){
    double a; string s; cin >> a >> s;
    if(s == "BTC") ans += a * 380000.0;
    else ans += a;
  }
  cout << ans << endl;
}

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

int main(){
    int n; cin>>n;
    // tuple:n個の型の値を保持することが出来る
    vector<tuple<string,int,int>> a;
    for(int i=1;i<=n;i++){
        // tieで複数の変数を代入する
        string s; cin>>s;
        int p; cin>>p;
        p=-p;
        a.push_back(tie(s,p,i));
    }
    sort(a.begin(),a.end());
    rep(i,n) cout<<get<2>(a[i])<<endl;
    return 0;
}


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

Measured memory_bytes: 13908
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
typedef long long int ll;
static const int MAX_H = 50;
static const int MAX_W = 50;
 
int H, W;
int map[MAX_H][MAX_W];
int dp[MAX_H + 1][MAX_W + 1];
 
int main(void){
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char c;
            cin >> c;
            if(c != '\n') map[i][j] = c - '0';
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i < H; i++) dp[i][0] = dp[i - 1][0] + map[i][0];
    for(int j = 1; j < W; j++) dp[0][j] = dp[0][j - 1] + map[0][j];
    for(int i = 1; i < H; i++){
        for(int j = 1; j < W; j++){
            dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]) + map[i][j];
        }
    }
    cout << dp[H - 1][W - 1] << endl;
    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define mod 998244353
#define ll long long
using namespace std;

struct ca
{
  long  si,ei;
};


int binarySearch(vector<int> arr, int l, int r, int x) 
{ 
    if (r >= l) { 
        int 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; 
} 

int prime[1000001]={};

long power(long x,  long y, long p)  
{  
    long res = 1;     
  
    x = x % p; 
   
    if (x == 0) return 0; 
  
    while (y > 0)  
    {  
         
        if (y & 1)  
            res = (res*x) % p;  
  
        
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  

void pr()
{
  prime[1]=0;

 for(int i=2;i*i<1000001;i++)
  if(prime[i]==0)
  for(int j=i*i;j<1000001;j+=i)
  prime[j]=1;

}

int countSetBits( int n) 
{ 
     int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 

long sum=0;




int main()
{

  //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

   //pr();
  int t;
   //cin>>t;
  t=1;
  int id=1;

  while(t--)
{
  
int s,w;
   cin>>s>>w;

if(w>=s)
 cout<<"unsafe";

else
  cout<<"safe";
}


return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> ss(h);
    for(auto& s : ss) cin >> s;
    
    vector<vector<int>> hmap(h, vector<int>(w));
    vector<vector<int>> vmap(h, vector<int>(w));
    
    for(int y = 0; y < h; ++y)
    {
        int run_begin = 0;
        int run_end = 0;
        bool in_run = false;
        for(int x = 0; x < w; ++x)
        {
            if(ss[y][x] == '.' && !in_run)
            {
                run_begin = x;
                in_run = true;
            }
            if(ss[y][x] == '#' && in_run)
            {
                run_end = x;
                const int n = max(0, run_end - run_begin);
                for(int ir = run_begin; ir < run_end; ++ir)
                {
                    hmap[y][ir] = n;
                }
                in_run = false;
            }
        }
        if(in_run)
        {
            run_end = w;
            const int n = max(0, run_end - run_begin);
            for(int ir = run_begin; ir < run_end; ++ir)
            {
                hmap[y][ir] = n;
            }
            in_run = false;
        }
    }
    
    for(int x = 0; x < w; ++x)
    {
        int run_begin = 0;
        int run_end = 0;
        bool in_run = false;
        for(int y = 0; y < h; ++y)
        {
            if(ss[y][x] == '.' && !in_run)
            {
                run_begin = y;
                in_run = true;
            }
            if(ss[y][x] == '#' && in_run)
            {
                run_end = y;
                const int n = max(0, run_end - run_begin);
                for(int ir = run_begin; ir < run_end; ++ir)
                {
                    vmap[ir][x] = n;
                }
                in_run = false;
            }
        }
        if(in_run)
        {
            run_end = h;
            const int n = max(0, run_end - run_begin);
            for(int ir = run_begin; ir < run_end; ++ir)
            {
                vmap[ir][x] = n;
            }
            in_run = false;
        }
    }
    /*
    for(int y = 0; y < h; ++y)
    {
        for(int x = 0; x < w; ++x)
        {
            cout << hmap[y][x] << ',';
        }
        cout << '\n';
    }
    cout << "----\n";
    for(int y = 0; y < h; ++y)
    {
        for(int x = 0; x < w; ++x)
        {
            cout << vmap[y][x] << ',';
        }
        cout << '\n';
    }
    cout << "----\n";
    */
    int maxfill = 0;
    for(int y = 0; y < h; ++y)
    {
        for(int x = 0; x < w; ++x)
        {
            maxfill = max(maxfill, hmap[y][x] + vmap[y][x] - 1);
        }
    }
    cout << maxfill << '\n';
    return 0;
}


Measured memory_bytes: 35712
#include <stdio.h>

#define N 100

int main(){

  int i,j,A[N],n,tmp,count=0,mini;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<n;i++){
    mini = i;
    for(j=i;j<n;j++){
      if(A[j]<A[mini]) mini = j;
    }
    if(A[i]>A[mini]) count++;
    tmp = A[i];
    A[i] = A[mini];
    A[mini] = tmp;
  }
  
  for(i=0;i<n;i++){
    if(i==n-1) printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }

  printf("%d\n",count);

  return 0;
}

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

int main() {
    int q_size, num_query; scanf("%d%d", &q_size, &num_query);
    int command, t, x;
    priority_queue<int> pq[q_size];
    
    for (int i = 0; i < num_query; ++i) {
        scanf("%d%d", &command, &t);
        switch (command) {
            case 0:
                scanf("%d", &x);
                pq[t].push(x);
                break;
            case 1:
                if (!pq[t].empty()) printf("%d\n", pq[t].top());
                break;
            case 2:
                if (!pq[t].empty()) pq[t].pop();
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 4180
import java.util.Scanner;

public class Main {

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

		while (true) {
			int h = scan.nextInt();
			int w = scan.nextInt();

			if (1 <= h && h <= 300 && 1 <= w && w <= 300) {
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						System.out.print("#");
					}
					System.out.println("");
				}
				System.out.println("");
			} else if (h == 0 && w == 0) {
				break;
			}
		}
	}
}

Measured memory_bytes: 33200
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long int;

int main()
{
	ll a, b, n;
	cin >> a >> b >> n;
	ll x = n / b * b - 1;
	cout << max((a * x) / b - a * (x / b), (a * n) / b - a * (n / b)) << endl;
	
	return 0;
}

Measured memory_bytes: 3592
def main():
    S = input()
    num = {}
    for i in S:
        if i not in num:
            num[i] = 1
        else:
            num[i] += 1

    if(len(num) == 2):
        for i in num.keys():
            if num[i] != 2:
                print("No")
                return 0
            print("Yes")
            return
    else:
        print("No")

main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n100,n10,n1;
  int diff=753;
  for(int i = 0; i< s.size()-2;i++){
    int temp = 0;
    int tempdif = 0;
    n100 = s.at(i) - '0';
    n10 = s.at(i+1) - '0';
    n1 = s.at(i+2) - '0';
    temp = 100*n100 + 10*n10 + n1;
    if(temp>753) tempdif = temp-753;
    else tempdif = 753 - temp;

    if(tempdif < diff) diff = tempdif;

  }
  cout << diff << endl;
  return 0;
}

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

map<string, int> cost;

int main() {
	int n; cin >> n;
	string s[n]; for(int i = 0; i < n; ++i) cin >> s[i];
	priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>> pq;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			int in = s[i].size();
			int jn = s[j].size();
			if(in <= jn) continue;
			string pre = s[i].substr(0, jn);
			if(pre != s[j]) continue;
			string to = s[i].substr(jn);
			pq.emplace(in, to);
		}
	}
	while(pq.size()) {
		int cos;
		string from;
		tie(cos, from) = pq.top();
		pq.pop();
		if(cost.count(from)) {
			if(cost[from] <= cos) continue;
		}
		cost[from] = cos;
		for(int i = 0; i < n; ++i) {
			int fn = from.size();
			int in = s[i].size();
			if(fn < in) {
				if(from != s[i].substr(0, fn)) continue;
				string to = s[i].substr(fn);
				if(from == to) continue;
				int tn = to.size();
				pq.emplace(cos + tn, to);
			} else {
				if(from.substr(0, in) != s[i]) continue;
				string to = from.substr(in);
				if(from == to) continue;
				int tn = to.size();
				if(tn == 0) {
					cout << cos << endl;
					return 0;
				}
				pq.emplace(cos, to);
			}
		}
	}
	cout << 0 << endl;
	return 0;
}




Measured memory_bytes: 3372
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    new_s=""
    for ss in s:
        if ss!='x':
            new_s+=ss
    if new_s[::-1]!=new_s:
        print(-1)
        sys.exit()
    right=len(s)-1
    left=0
    ans=0
    while right-left>0:
        if s[right]!=s[left]:
            if s[right]=='x':
                ans+=1
                right-=1
            elif s[left]=='x':
                ans+=1
                left+=1
        else:
            right-=1
            left+=1
    print(ans)



if __name__=='__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h;
  for(int i=0; i<n; i++){
    int hi;
    cin >> hi;
    h.push_back(hi);
  }
  sort(h.begin(), h.end(), greater<int>());
  int i;
  for(i=0; i<n; i++){
    if(h[i]<k) break;
  }
  cout << i;
  return 0;
}

Measured memory_bytes: 892
import java.util.*;

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

        int N = sc.nextInt();

        for(int i=0; i<N; i++){
            if(sc.next().equals("Y")){
                System.out.println("Four");
                break;
            }
            if(i==N-1){
                System.out.println("Three");
            }
        }
    } 
}

Measured memory_bytes: 21972
import queue
import numpy as np

num = list(map(int,input().split()))
field = [list(input()) for i in range(num[0])]
seen = np.zeros((num[0],num[1]))

step_r = [1,0,-1,0]
step_c = [0,1,0,-1]
q_r = queue.Queue()
q_c = queue.Queue()
sign = 0
white = 0
q_r.put(0)
q_c.put(0)

for i in range(num[0]):
  for j in range(num[1]):
    if field[i][j] == ".":
      white = white + 1

while not q_r.empty():
  r = q_r.get()
  c = q_c.get()
  for i in range(4):
    next_r = r + step_r[i]
    next_c = c + step_c[i]
    
    if (next_r<0) or (num[0]<=next_r) or (next_c<0) or (num[1]<=next_c) or (field[next_r][next_c] == "#"):
      continue
      
    if seen[next_r][next_c] == 0:
      q_r.put(next_r)
      q_c.put(next_c)
      seen[next_r][next_c] = seen[r][c] + 1
      if (next_r == num[0]-1) and (next_c == num[1]-1):
        g_r = next_r
        g_c = next_c
        sign = 1
        break
 
  if sign == 1:
    break

if sign == 1:
  ans = white - (seen[g_r][g_c] + 1)
elif sign == 0:
  ans = -1

print(int(ans))

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

int main() {
    ll n;
    cin >> n;
    ll ans = 0, p = -1;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    h.push_back(10000000000);
    rep(i, n) {
        if(h[i] < h[i + 1]) {
            ans = max(ans, i - p - 1);
            p = i;
        }
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int x, t;
	cin >> x >> t;
	if (x > t) {
		cout << x - t << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}



Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int n,k,h[100009],m[100009];

int main(){
    cin>>n>>k;
    for(int i =1;i<=n;i++){
        cin>>h[i];
        m[i] = 1e9;
    }
    m[1] = 0;
    for(int i = 1;i<=n;i++)
        for(int j = i+1;j<=i+k;j++)
            if(j<=n)
                m[j] = min(m[j],m[i]+ abs(h[i]-h[j]));
    cout<<m[n]<<endl;

}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 998244353;
const int MN = 100010;

int n;
int a[MN];

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);

	ll x = a[0];

	for (int i = 1; i < n; ++i) {
		ll t = __gcd(i, a[i]);
		x = x * t % MOD;
	}

	cout << x << endl;

	return 0;
}

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

int main() {
  ll n; cin >> n;
  vector<ll> v(n+1,0);
    ll cnt = 0;
    ll x=1; 
    while(x*x < n){
      ll y=1;
      while(y*y < n-x*x){
        ll z=1;
        while(z*z < n-x*x-y*y){
         ll f = x*x + y*y + z*z + x*y + y*z + z*x;
         if( f <= n )
           v[f]++;
         z++;
        }
        y++;
      }
      x++;
    }
  for(ll i=1; i<n+1; i++){
    cout << v[i] << endl;
  }
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(20) << fixed;
    ll n, m;
    cin >> n >> m;
    ll l = n * m / gcd(n, m);
    string s;
    cin >> s;
    string t;
    cin >> t;
    map<ll, char> mp;
    for (int i = 0; i < n; i++) {
        ll idx = l / n * i;
        mp[idx] = s[i];
    }
    for (int i = 0; i < m; i++) {
        ll idx = l / m * i;
        if (mp.count(idx) && mp[idx] != t[i]) {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N; cin >> N;
  int ans=0;
  v<int> A(N);
  rep(i,N) cin >> A[i];
  rep(i,60){
    int x=0;
    rep(j,N){
      if(A[j]>>i & 1) ++x;
    }
    int now=x*(N-x)%MOD;
    rep(j,i){
      now=now*2%MOD;
    }
    ans+=now%MOD;
  }
  cout << ans%MOD << endl;
  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

class UnionFind{
private:
	std::vector<int_fast32_t> par;
	size_t n;

public:
	UnionFind(){}
	UnionFind(size_t n):n(n){
		par.resize(n, -1);
	}

	uint_fast32_t find(uint_fast32_t x){
		return par[x] < 0 ? x : par[x] = find(par[x]);
	}

	size_t size(uint_fast32_t x){
		return -par[find(x)];
	}

	void unite(uint_fast32_t x, uint_fast32_t y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(size(x) < size(y)) std::swap(x, y);
		par[x] += par[y];
		par[y] = x;
	}

	bool same(uint_fast32_t x, uint_fast32_t y){
		return find(x) == find(y);
	}
};

const int64 mod = 1e9+7;

int32 toint(string s){
	int32 res = 0;
	REP(i, s.size()){
		res = (res*10+s[i]-'0');
	}
	return res;
}

int64 mpow(int64 x, int64 y){
	if(y == 0) return 1;
	if(y%2) return x*mpow(x, y-1)%mod;
	int64 ret = mpow(x, y/2);
	return ret*ret%mod;
}

int64 dp[20][10][2][2] = {};
string s;

int64 dfs(int32 dig = 0, int32 app = 0, bool tight = 1, bool l_z = 1){
	if(dig == s.size()){
		dp[dig][app][tight][l_z] = (app == 7);
		return dp[dig][app][tight][l_z];
	}
	int32 lim = tight ? s[dig]-'0' : 9;
	int64 &res = dp[dig][app][tight][l_z];
	res = 0;
	REP(i, lim+1){
		if(i == 3){
			res += dfs(dig+1, app|1, tight && (i == lim), 0);
		}else if(i == 5){
			res += dfs(dig+1, app|2, tight && (i == lim), 0);
		}else if(i == 7){
			res += dfs(dig+1, app|4, tight && (i == lim), 0);
		}
		if(i == 0 && l_z){
			res += dfs(dig+1, app, tight && (i == lim), 1);
		}
	}
	return res;
}

int main(void){
	memset(dp, -1, sizeof dp);
	cin >> s;
	cout << dfs() << endl;
}


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

using namespace std;

typedef long long ll;

const int N = 100010;

vector<int> g[N];

int used[N], k[N];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        ++k[a];
        ++k[b];
    }
    if (n == 2) {
        cout << "Second";
        return 0;
    }
    queue<int> q, w;
    for (int i = 1; i <= n; ++i) {
        if (k[i] == 1) {
            used[i] = 1;
            q.push(i);
        }
    }
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        bool f = false;
        for (int u : g[v]) {
            if (!used[u]) {
                used[u] = 1;
                f = true;
                for (int i : g[u]) {
                    if (--k[i] == 1 && !used[i]) {
                        w.push(i);
                    }
                }
                break;
            }
        }
        if (!f) {
            cout << "First";
            return 0;
        }
        if (q.empty()) {
            while (!w.empty()) {
                if (!used[w.front()]) {
                    q.push(w.front());
                }
                w.pop();
            }
        }
    }
    cout << "Second";
    return 0;
}

Measured memory_bytes: 6784
fun main(args: Array<String>) {
    var (N, W) = pairIntLong()
    val WV = Array(4) { mutableListOf<Long>() }
    var baseW = 0 //WV[0].first.toLong()
    repeat(N) {
        val (w, v) = pairIntLong()
        if (baseW == 0) baseW = w
        WV[w - baseW].add(v)
    }
    WV.forEach {
        it.sortDescending()
        it.add(0, 0)
    }
    var ans = 0L
    for (n0 in WV[0].indices)
    for (n1 in WV[1].indices)
    for (n2 in WV[2].indices)
    for (n3 in WV[3].indices) {
        val w0 = (baseW + 0L) * n0
        val w1 = (baseW + 1L) * n1
        val w2 = (baseW + 2L) * n2
        val w3 = (baseW + 3L) * n3
        if (w0 + w1 + w2 + w3 > W) continue
        val v0 = WV[0].subList(0, n0 + 1).sum()
        val v1 = WV[1].subList(0, n1 + 1).sum()
        val v2 = WV[2].subList(0, n2 + 1).sum()
        val v3 = WV[3].subList(0, n3 + 1).sum()
        ans = Math.max(ans, v0 + v1 + v2 + v3)
    }
    println(ans)
}
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


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

int main(){
    int n, i, data[100];
    cin >> n;
    for(i=0; i<n; i++){
        cin >> data[i];
    }
    for(i=n-1; i>=1; i--){
        cout << data[i] << ' ';
    }
    cout << data[0] << endl;
    return 0;
}   

Measured memory_bytes: 3092
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int n;
    cin>>n;
    bool ok=true;
    while (n--)
    {
        int x;
        cin>>x;
        if (x%2==0)
        {
            if (x%3==0||x%5==0)
                continue;
            else
                ok=false;
        }
    }
    if (ok)
        cout<<"APPROVED";
    else
        cout<<"DENIED";




}

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

struct UnionFind{
    vector<int> par;
    vector<int> siz;

    UnionFind(int n): par(n), siz(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            siz[i] = 1;
        }
    }

    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    int size(int x){
        if(par[x] == x) return siz[x];
        else return siz[x] = size(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx != ry){
            par[ry] = rx;
            siz[rx] += siz[ry];
        }
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }
};

signed main(){
    // cout << fixed << setprecision(10) << flush;

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

    vector<int> a(m), b(m);
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind uf(n);

    vector<int> ans(m);
    for(int i=m-1; i>=0; i--){
        int sa = uf.size(a[i]);
        int sb = uf.size(b[i]);
        if(uf.same(a[i], b[i])){
            ans[i] = 0;
        }
        else{
            ans[i] = sa*sb;
        }
        uf.unite(a[i], b[i]);
    }

    for(int i=0; i<m-1; i++){
        ans[i+1] += ans[i];
    }

    for(int i=0; i<m; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

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

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

int main(){
	int n,r,p,c;
	int card[64];
	while(cin>>n>>r,n|r){
		rep(i,n)card[i]=n-i;
		//p+c<=n+1
		rep(i,r){
			cin>>p>>c;
			int tmp[64];
			for(int k=0; k<c; k++){
				tmp[k] = card[p-1+k];
			}
			for(int k=0; k<p-1; k++){
				tmp[c+k] = card[k];
			}
			for(int k=p+c-1; k<n; k++){
				tmp[k] = card[k];
			}
			
			/*
			rep(k,n){
				printf("%d,",tmp[k]);
			}puts("");
			*/
			//copy
			rep(k,n){
				card[k]=tmp[k];
			}
		}
		printf("%d\n",card[0]);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define EXCEPTERROR cout << "-1" << endl;
#define rep(k,nu)    for(int i=k; i<nu;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
#define size_a(array) sizeof(array) / sizeof(array[0])
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}
const double PI = acos(-1);


int main(){
    int x, y, z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);

    cout << x << " " << y << " " << z << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3556
#include <cstdio>
#include <cstring>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int T = 8010;

int n, ss[2], f[2][2][2 * T + 10], fl, now;
char s[T];

int main()
{
    scanf("%s", s + 1);
    n = strlen(s + 1); s[n + 1] = 'T';
    scanf("%d%d", &ss[0], &ss[1]);
    f[0][0][T] = f[1][0][T] = 1;
    FOR(j, 1, n + 1) if (s[j] == 'F') ++now;
    else
    {
        if (now == j - 1) f[0][0][T] = 0, f[0][0][T + now] = 1; else
        {
            FOR(i, 1, 2 * T)
                if (i - now > 0 && i + now <= 2 * T) f[fl][1][i] = f[fl][0][i - now] | f[fl][0][i + now]; else
                    f[fl][1][i] = i - now > 0 ? f[fl][0][i - now] : f[fl][0][i + now];
            FOR(i, 1, 2 * T) f[fl][0][i] = f[fl][1][i], f[fl][1][i] = 0;
        }
        fl ^= 1; now = 0;
    }
    if (f[0][0][ss[0] + T] && f[1][0][ss[1] + T]) puts("Yes"); else puts("No");
    return 0;
}


Measured memory_bytes: 384
def main():
    from sys import stdin, stdout

    def read():
        return stdin.readline().rstrip('\n')

    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)

    def read_int():
        return int(read())

    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]

    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)

    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)

    n = read_int()
    if n == 1:
        write(0)
        return

    top = int(n**0.5)
    out = 0
    for c in range(1, top+1):
        c2 = n // c - 1
        if n // c2 == n % c2:
            out += c2
    write(out)

main()


Measured memory_bytes: 38640
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

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


//std::ios::sync_with_stdio(false);
int a[200005];
main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int n,i,ans=0;
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	map<int,int>cnt;
	cnt.clear();
	fd(i,n-1,0){
		ans+=cnt[i+a[i]];
		cnt[i-a[i]]++;
	}
	cnt.clear();
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 27872