akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void add(int k, const Monoid &x) {
	k += sz;
	seg[k] += x;
	while(k >>= 1) {
	  seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
	}
  }

  Monoid query(int a, int b) {//半開区間
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};
int main(){
	int N,Q;
	scan(N>>Q);
	SegmentTree<int> seg(N,[](int a, int b){return min(a,b);},(1LL<<31)-1);
	rep(i,Q){
		int T,X,Y;
		scan(T>>X>>Y);
		if(T==0){
			seg.update(X,Y);
		}
		else{
			prin(seg.query(X,Y+1));
		}
	}
	return 0;
}



Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    ll N;
    cin >> N;
    vector<ll>v(N + 2, 0);
    for(ll i = 1; i <=N; i++)cin >> v[i];
    ll ans = 0;
    for(ll i = 0; i + 1 < v.size(); i++)ans += abs(v[i] - v[i + 1]);
    for(ll i = 1; i <= N; i++){
        cout << ans - abs(v[i - 1] - v[i]) - abs(v[i] - v[i + 1]) + abs(v[i - 1] - v[i + 1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

set<ll> a;
ll red = 0;
int main() {
	ll n; cin >> n;

	rep(i, 0, n) {
		ll x; cin >> x;
		if (x < 400) a.insert(0);
		else if (x < 800) a.insert(1);
		else if (x < 1200) a.insert(2);
		else if (x < 1600) a.insert(3);
		else if (x < 2000) a.insert(4);
		else if (x < 2400) a.insert(5);
		else if (x < 2800) a.insert(6);
		else if (x < 3200) a.insert(7);
		else red++;
	}
	if (a.size() == 0) {
		cout << 1 << ' ' << red << endl;
	}
	else {
		cout << a.size() << ' ' << a.size() + red << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <cmath>
#include <map> 
#include <iostream>
#include <cctype>
#include <utility> // 包含pair 
using namespace std;
typedef long long LL;
const int MAXN = 10 + 10;
int a[MAXN];
stack<int> s1, s2; // 建立两个栈，用于模拟小球进栈的过程
// 当前第idx个元素 
bool dfs(int idx) {
	if (idx == 10) {
		return true; // 所有元素都遍历完了(思考这里是true还是false) 应该是true 
	}
	if (s1.empty() || a[idx] > s1.top()) {
		s1.push(a[idx]);
		if (dfs(idx + 1)) {
			s1.pop(); // 回溯
			return true; 
		}
	}
	if (s2.empty() || a[idx] > s2.top()) {
		s2.push(a[idx]);
		if (dfs(idx + 1)) {
			s2.pop();
			return true;
		}
	}
	return false; // 都不满足则返回假 
}

int main() {
	// ios::sync_with_stdio(false);
	int T;
	scanf("%d", &T);
	while (T--) {
		// while (!s1.empty()) s1.pop();
		// while (!s2.empty()) s2.pop(); 如果是回溯法的话，其实不需要这两行 
		for (int i = 0; i < 10; i++) {
			scanf("%d", &a[i]);
		}
		if (dfs(0)) printf("YES\n");
		else printf("NO\n");
	}
	
    return 0;
}


Measured memory_bytes: 3120
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)

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

int main(){
	int n=read(),m=read();
	if(m%2==0){
		ll ans=0;
		ans=ans+(n/m)*1ll*(n/m)*(n/m);
		m=m/2;
		n=n/m;n=(n+1)/2;
		ans=ans+n*1ll*n*n;
		cout<<ans<<endl;
	}
	else{
		n=n/m;
		cout<<n*1ll*n*n<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        int n;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++) 
            cin >> a[i];

        int mx = 1e18, curr = 1, f = 0;
        for(int i = 0; i < n; i++) {
            //cout << i << ": " << mx / a[i] << ' ' << curr << ' ' << (mx / a[i] <= curr) << '\n';
            if(a[i] == 0) {
                f = 0;
                curr = 0;
                break;
            }
            else if(mx / a[i] >= curr)
                curr *= a[i];
            else {
                // cout << "Overflow: " << i << '\n';
               f = 1;
            }
        }

        if(f)
            curr = -1;
        cout << curr << '\n';
    }
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 4592
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int s, w;
    cin >> s >> w;
    if (s <= w) {
        cout << "unsafe" << endl;
    }   
    else {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  int from_left[s.size()];
  for (int i = 0; i < s.size(); ++i) {
    if (i == 0)
      from_left[0] = 1;
    else if (s[i] == s[i - 1]) {
      from_left[i] = from_left[i - 1];
    } else {
      from_left[i] = from_left[i - 1] + 1;
    }
  }

  int from_right[s.size()];
  for (int i = s.size() - 1; i >= 0; --i) {
    if (i == s.size() - 1)
      from_right[s.size() - 1] = 1;
    else if (s[i] == s[i + 1]) {
      from_right[i] = from_right[i + 1];
    } else {
      from_right[i] = from_right[i + 1] + 1;
    }
  }

  long long ret = 10000000;
  for (int i = 0; i < s.size(); ++i) {
    ret = min(ret, (long long)(from_left[i] + from_right[i]));
  }

  cout << ret - 2 << endl;

  //int from_left = 0;
  //int left_end = 0;
  //for (int i = 0; i < s.size(); ++i) {
  //  if (i == 0)
  //    from_left = 1;
  //  else if (s[i] == s[i - 1])
  //    ++from_left;
  //  else if (s[i] != s[i - 1] || i == s.size() - 1) {
  //    left_end = i - 1;
  //    break;
  //  }
  //}
  //int from_right = 0;
  //int right_end = 0;
  //for (int i = s.size() - 1; i >= 0; --i) {
  //  if (i == s.size() - 1)
  //    from_right = 1;
  //  else if (s[i] == s[i + 1])
  //    ++from_right;
  //  else if (s[i] != s[i + 1] || i == 0) {
  //    right_end = i;
  //    break;
  //  }
  //}

  //int ret = 0;
  //while (true) {
  //  if (left_end >= right_end)
  //    break;

  //  cout << left_end << " " << right_end << endl;

  //  if (from_left > from_right) {
  //    int prev_left_end = left_end;
  //    for (int i = left_end + 1; i < s.size(); ++i) {
  //      if (s[i] != s[i - 1] || i == s.size() - 1){
  //        left_end = i - 1;
  //        break;
  //      }
  //    }
  //    from_left += left_end - prev_left_end;
  //    ++ret;
  //  } else {
  //    int prev_right_end = right_end;
  //    for (int i = right_end - 1; i >= 0; --i) {
  //      if (s[i] != s[i + 1] || i == 0) {
  //        right_end = i + 1;
  //        break;
  //      }
  //    }
  //    from_right += prev_right_end - right_end;
  //    ++ret;
  //  }
  //}

  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=2000000000000000000;
int mod;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,dp[200010];
bool used[200010];
vector<int>v[200010];
void dfs1(int x){
    used[x]=true;
    dp[x]=1;
    for(int i:v[x]){
        if(!used[i]){
            dfs1(i);
            dp[x]*=(dp[i]+1);
            dp[x]%=mod;
        }
    }
}
void dfs2(int x,int dp_par=-1){
    used[x]=true;
    int k=v[x].size();
    vector<int>c1(k),c2(k);
    rep(i,k){
        int u=v[x][i];
        if(used[u]){
            c1[i]=c2[i]=(dp_par+1)%mod;
            dp[x]*=dp_par+1;
            dp[x]%=mod;
        }
        else{
            c1[i]=c2[i]=(dp[u]+1)%mod;
        }
    }
    rep(i,k-1){
        c1[i+1]*=c1[i];
        c1[i+1]%=mod;
    }
    for(int i=k-1;i>0;i--){
        c2[i-1]*=c2[i];
        c2[i-1]%=mod;
    }
    rep(i,k){
        int u=v[x][i];
        if(!used[u]){
            dfs2(u,(i?c1[i-1]:1)*(i!=k-1?c2[i+1]:1)%mod);
        }
    }
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>mod;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    fill(used,used+n,false);
    dfs1(0);
    fill(used,used+n,false);
    dfs2(0);
    rep(i,n)cout<<dp[i]<<endl;
    return 0;
}

Measured memory_bytes: 21760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
     
     
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    int mx = -1e9, my = 1e9, n, m;
    cin >> n >> m  >> mx >> my;
    for (int i = 0; i < n; ++i)
    {
        cin >> x;
        mx = max(mx, x);
    }
    for (int i = 0; i < m; ++i)
    {
        cin >> y;
        my = min(my, y);
    }
    cout << (mx < my ? "No War" : "War");
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        int n = sc.nextInt();
        Arrays.sort(a);
        long ans = 0;
        for (int i = 0; a[2] * i <= n; i++) {
            for (int j = 0; a[2] * i + a[1] * j <= n; j++) {
                long sum = a[2] * i + a[1] * j;
                if ((n - sum) % a[0] == 0) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 23124
masu = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
li = [int(input()) for _ in range(n)]
check = [[0]*3 for _ in range(3)]


for num in li:
    for i in range(3):
        for j in range(3):
            if masu[i][j] == num:
                check[i][j] = 1

for row in check:
    if all(row) == 1:
        print('Yes')
        exit()
for t in range(3):
    count = 0
    for row in check:
        if row[t] == 1:
            count += 1
    if count == 3:
        print('Yes')
        exit()
if check[0][0] + check[1][1] + check[2][2] == 3:
    print('Yes')
    exit()
if check[0][2] + check[1][1] + check[0][2] == 3:
    print('Yes')
    exit()
    
print('No')

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int n;
  cin >> n;
  int rhs = 0;
  int tot = 0;
  while(n--) {
    int a;
    cin >> a;
    rhs = max(rhs, a);
    tot += a;
  }
  cout << tot - rhs/2 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, i, j, k;
	bool valid = true;
	cin >> n;
	vector<int> t(n + 1), x(n + 1), y(n + 1);
	t[0] = 0; x[0] = 0; y[0] = 0;
	for (i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
		if ((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) > t[i] - t[i - 1])) valid = false;
		if ((x[i] + y[i]) % 2 != t[i] % 2) valid = false;
	}
	if (valid) cout << "Yes\n";
	else cout << "No\n";


	return 0;
}


Measured memory_bytes: 1408
N, M = map(int, input().split())
INF = float('inf')
G = [[INF] * N for i in range(N)]
for i in range(M):
    s, t, d = map(int, input().split())
    G[s][t] = d


dp = [[INF] * N for i in range(1 << N)]
dp[1][0] = 0
for bs in range(1 << N):
    for n in range(N):
        if dp[bs][n] == INF:
            continue
        for to in range(N):
            if bs & (1 << to):
                continue
            next_index = bs | (1 << to)
            dp[next_index][to] = min(dp[next_index][to], dp[bs][n] + G[n][to])


ans = INF
for fr in range(1, N):
    ans = min(ans, dp[-1][fr] + G[fr][0])
print(ans if ans != INF else -1)



Measured memory_bytes: 15456
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int L = 15, N = 200100;
vector <int> mp[L];
int n, ans[1000010], mul[L];
char st[N];
void dfs(int k, int fm, int to){
	if (k == n){
		ans[fm] = to;
		return;
	}
	for (int i = 0; i < 3; i++){
		mp[k + 1].clear();
		int x = i;
		for (unsigned j = 0; j < mp[k].size(); j++){
			if (mp[k][j] == 0){
				x = x + 1;
				if (x % 3 == 0){
					x = 0;
					mp[k + 1].push_back(0);
				}
			}
			else {
				x = x * 2 % 3;
				if (mp[k + 1].size() > 0 && mp[k + 1][mp[k + 1].size() - 1] == 1)
					mp[k + 1].pop_back();
					else mp[k + 1].push_back(1);
			}
		}
		dfs(k + 1, fm + i * mul[k], to + x * mul[k]);
	}
}
int main(){
	read(n);
	scanf("\n%s", st + 1);
	int l = strlen(st + 1); 
	for (int i = 1; i <= l; i++){
		int t;
		if (st[i] == 'R') t = 0; else t = 1;
		if (t == 1 && mp[0].size() > 0 && mp[0][mp[0].size() - 1] == 1){
			mp[0].pop_back();
			continue;
		}
		mp[0].push_back(t);
	}
	mul[0] = 1;
	for (int i = 1; i <= n; i++) mul[i] = mul[i - 1] * 3;
	dfs(0, 0, 0);
	for (int i = 0; i < mul[n]; i++)
		printf("%d%c", ans[i], (i == mul[n] - 1) ? '\n' : ' ');
	return 0;
}



Measured memory_bytes: 7816
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

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

		int[] val = new int[N + 1];

		List<Integer>[] edgeList = new ArrayList[N + 1]; //各nodeが持つedgeを集約する

		for (int i = 1; i <= N; i++) {
			val[i] = sc.nextInt();
			edgeList[i] = new ArrayList<Integer>();
		}


		//辺をノードごとに集約
		for (int i = 0; i < M; i++) {
			int edge_a = sc.nextInt();
			int edge_b = sc.nextInt();
			edgeList[edge_a].add(edge_b);
			edgeList[edge_b].add(edge_a);
		}

		int ans = 0;

		//比較
		for (int i = 1; i <= N; i++) {
			int let = 0;
			for (int j = 0; j < edgeList[i].size(); j++) {
				let = Math.max(let, val[edgeList[i].get(j)]);
			}
			if (let - val[i] < 0) {
				ans++;
			}
		}

		System.out.println(ans);


	}
}

Measured memory_bytes: 71672
#include<iostream>
using namespace std;
#include<cstring>
#include<cstdio> 
int a[20];
char s[20];
int main()
{
	scanf("%s",&s);
//	puts(s);
    int k=-1;
	for(int i=0;i<strlen(s);i++)
	{
	
	if(s[i]=='0')
	{
	k++;
	a[k]=0;	
	}
	if(s[i]=='1')
	{
	k++;
	a[k]=1;
	}
	if(s[i]=='B')
	if(k>=0)
	k--; 
		
	}
	for(int i=0;i<=k;i++)
	{
		cout<<a[i];
	}
	return 0;
}

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

///////////////////////////////////////////
const long long int INF = INT64_MAX;
//const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////
ll n;string s;
ll rui[300001]={0};//1:r,l;0

int main(){
    cin>>n>>s;
    rep(i,n){
        if(s[i]=='E' && i>0){
            rui[i]=1+rui[i-1];
        }else if(s[i]=='E' && i==0){
            rui[0]=1;
        }else{
            rui[i]=rui[i-1];
        }
    }
    ll ans = n;
    rep(i,n){
            if(i==0){
                chmin(ans,rui[n-1]-rui[0]);
            }else if(i==n-1){
                chmin(ans,n-1-rui[n-2]);
            }else{
                chmin(ans,i-rui[i-1] + rui[n-1]-rui[i]);
            }
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> dp(n,1000);
  rep(i,n)rep(j,n){
    if(i>=j) continue;
    if(a[i]>=a[j]) continue;
    ll v = (dp[i]/a[i])*a[j] + dp[i]%a[i];
    rep(k,n) if(j<=k) dp[k] = max(dp[k],v);
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>

using namespace std;

#define MAX_CITY_NUM 15
#define MAX 100000000

int D[MAX_CITY_NUM][MAX_CITY_NUM];

int dp[MAX_CITY_NUM][1 << MAX_CITY_NUM];

int tsp(int v, int b, int city_num){
    int rtn = MAX;
    //??¨????????????????¨??????????
    if(b == (1 << city_num) - 1){
        if (D[v][0] == -1) {
            return rtn;
        }else{
            return D[v][0];
        }
    }
    
    for (int i = 0; i < city_num; i++) {
        //????¨?????????????????¨??????????
        if (
            !(b & (1 << i))
            &&
            D[v][i] != -1
            )
        {
            int cost = dp[i][b | (1 << i)] != 0 ? dp[i][b | (1 << i)] : tsp(i, b | (1 << i), city_num);
            dp[i][b | (1 << i)] = cost;
            rtn = min( rtn, D[v][i] + cost);
        }
    }
    
    return rtn;
}



int main(){
    
    int V, E, frm, to, cost, ans;
    
    cin >> V >> E;
    
    //-1??§?????????
    memset(D, -1, sizeof(D));
    for (int i = 0; i < E; i++){
        cin >> frm >> to >> cost;
        D[frm][to] = cost;
    }
    
    ans = tsp(0, 1, V);
    
    if (ans >= MAX) {
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2760
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
 
int main(){
    
    size_t n;
    size_t cnt = 0;
 
    std::cin >> n;
 
    std::vector<size_t> a(n + 1), b(n);
 
    for(auto&& e : a){
        std::cin >> e;
    }
 
    for(auto&& e : b){
        std::cin >> e;
    }
 
    for(size_t i = 0; i < n; i++){
        if(a[i] >= b[i]){
            cnt += b[i];
        }else{
            cnt += a[i];
            b[i] -= a[i];
 
            if(a[i + 1] >= b[i]){
                a[i + 1] -= b[i];
                cnt += b[i];
            }else{
                cnt += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
 
    std::cout << cnt << std::endl;
 
    return 0;
}


Measured memory_bytes: 1792
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

# import fractions

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)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

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


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

    N = ii()
    D = il()
    ret = 0
    for x, y in itertools.combinations(D, 2):
        ret += x * y
    print(ret)


if __name__ == '__main__':
    main()


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

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

  int A, B, K; cin >> A >> B >> K;
  for (int x = A; x <= min(A+K-1, B); x++)
    cout << x << "\n";
  for (int x = max(A+K, B-K+1); x <= B; x++)
    cout << x << "\n";
}

Measured memory_bytes: 256
N = input()
n = list(N)
str = n[0] + n[0] + n[0]
num = int(str)
big = int(n[0]) + 1
big_num = 100 * big + 10 * big + big
number = int(N)
if number <= num:
  print(num)
else:
  print(big_num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int digitsum(int n) {
    int res = 0;
    string s = to_string(n);
    for(int i = 0; i < s.size(); i++) {
        res += (s[i] - '0');
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = INF;
    for(int i = 1; i < n; i++) {
        chmin(ans, digitsum(i) + digitsum(n - i));
    }
    print(ans);
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, long long K, std::string S) {
  S[K-1] ^= 32;
  cout << S << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::string S;
  std::cin >> S;
  solve(N, K, S);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long ans=0;
    vector<long long> a(n);
    for(int i=0;i<=n;i++){
        cin >> a[i];
    }
    long long temp;
    for(int i=0;i<n;i++){
        if(a[i]>0){
            ans+=a[i]/2;
            a[i]=a[i]%2;
            if(i!=n-1&&a[i+1]>0&&a[i]>0){
                temp = min(a[i+1],a[i]);
                a[i+1]-=temp;
                a[i]-=temp;
                ans+=temp;
            }
            
        }
    }
    cout << ans << endl;
}

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

int main() {
        int L, A, B, C, D;

        cin >> L >> A >> B >> C >> D;

        int M, G;
        G = A / C;
        if (A % C) G++;
        M = B / D;
        if (B % D) M++;

        cout << L - max(M, G) << endl;
        return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main() {

  string num_str[11] = {
    
    "0111111",
    "0000110",
    "1011011",
    "1001111",
    "1100110",
    "1101101",
    "1111101",
    "0100111",
    "1111111",
    "1101111",
    "0000000"

  };

  int n;
  int num,num_prev;

  string signal;


  while(cin >> n) {

    if(n==-1) break;

    signal="0000000";
    num_prev=10;

    for(int i=0;i<n;i++) {

      cin >> num;

      for(int j=0;j<7;j++) {

	signal[j]=((num_str[num_prev][j]-48)^(num_str[num][j]-48)+48);

      }

      num_prev=num;

      cout << signal << endl;

    }

  }

  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
#define pb push_back  

int main()
{
   IOS
   
   ll n,k,i;
   cin>>n>>k;
   
   ll h[n+1];
   ll dp[n+1];

   for(i=1;i<=n;i++)
   {
   	cin>>h[i];
   }
   dp[1]=0;
   dp[0]=0;
   for(i=2;i<=n;i++)
   {
   	dp[i] = INT_MAX;
   	for(ll step = 1;step<=k;step++)
   	{
   		if(i>step)
   		{
   		 dp[i] = min(dp[i],abs(h[i]-h[i-step]) + dp[i-step]);
        }  
   }
   }
   cout<<dp[n]<<endl;

}

Measured memory_bytes: 5164
#include<iostream>
#include<string>
using namespace std;
int main(){
	string inp, sentence = "";
	int numOfChar[26] = { 0 };
	while (cin >> inp){
		sentence += inp;
		}
	for (int i = 0; i < sentence.size(); i++){
		if ('a' <= sentence[i] && sentence[i] <= 'z')
			numOfChar[(int)sentence[i] - 'a']++;
		else if ('A' <= sentence[i] && sentence[i] <= 'Z')
			numOfChar[(int)sentence[i] - 'A']++;
	}
	for (int i = 0; i <26; i++){
		cout << (char)(i + 'a') << " : " <<numOfChar[i]<< endl;
	}
}


Measured memory_bytes: 3156
#! python3

def main():
    n, m = map(int, input().split())
    hlist = list(map(int, input().split()))
    tenbou_set = set(range(1, (n+1)))
    for i in range(m):
        a, b = map(int, input().split())
        if hlist[(a-1)] < hlist[(b-1)]:
            tenbou_set.discard(a)
        elif hlist[(a-1)] > hlist[(b-1)]:
            tenbou_set.discard(b)
        elif hlist[(a-1)] == hlist[(b-1)]:
            tenbou_set.discard(a)
            tenbou_set.discard(b)

    print(len(tenbou_set))

main()

Measured memory_bytes: 22396
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
    int r,D,x2k;;
    int x[100];
    cin >> r >> D >> x2k;

    x[0] = x2k;

    for (int i = 1; i < 11; i++)
    {
        x[i]=r*x[i-1] - D;
    }

    for (int i = 1; i < 11; i++)
    {
        cout << x[i] << endl;
    }
    
    

    
    }


Measured memory_bytes: 256
def binary_search(h, left, right, a,b):
    d = a-b
    while left + 1 < right:
        k = (left+right)//2
        cost = 0
        for i in h:
            tmp = i - k * b
            if tmp <= 0:
                continue
            cost += (tmp + d - 1) // d
        # print(left,right, k, cost)
        if cost > k:
            left = k
        else:
            right = k
    return right


n,a,b = map(int,input().split())
h = []
cnt = 0
for _ in range(n):
    i = int(input())
    h.append(i)
    cnt += (i+a-1)//a
print(binary_search(h, -1, cnt+1,a,b))


Measured memory_bytes: 7108
#include <cstdio>
#include <algorithm>
#define maxn 2005
#define LL long long
using namespace std;
LL dp[maxn][maxn];
struct node{
	int seq,val;
}a[maxn];
int cmp(node a,node b){
	return a.val<b.val;
}
int main(){//大的值最后放
	int i,j,len,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i].val),a[i].seq=i;
	sort(a+1,a+1+n,cmp);//按值自小到大排序
	for(i=1;i<=n;i++)dp[i][i]=(LL)a[1].val*abs(a[1].seq-i);//神奇的初始化
	for(len=2;len<=n;len++)//区间长度
		for(i=1;i+len-1<=n;i++){//左边界
			j=i+len-1;//右边界
			dp[i][j]=max(dp[i+1][j]+(LL)a[len].val*abs(a[len].seq-i),dp[i][j-1]+(LL)a[len].val*abs(a[len].seq-j));
		}
	printf("%lld\n",dp[1][n]);
	return 0;
}

Measured memory_bytes: 24360
from itertools import permutations


N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]
cost = [[0] * 3 for _ in range(C)]

for i in range(N):
    for j in range(N):
        for k in range(C):
            cost[k][(i + j) % 3] += D[c[i][j] - 1][k]

ans = min(
    sum(cost[c][i] for i, c in enumerate(colors))
    for colors in permutations(range(C), 3)
)
print(ans)


Measured memory_bytes: 76548
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int sum[100005];
int main() {
  int n,k;
  cin>>n>>k;
  string s1;
  cin>>s1;
  int s[100005];
  for (int i=0; i<n; i++) {
    s[i]=s1[i]-'0';
  }
  int i=0,j=0;
  if (s[0]==0) {
    j=1;
    sum[0]=0;
  }
  while (i<n) {
    int x=s[i],sum1=0;
    while (i<n) {
      if (s[i]==x) {
	sum1++;
	i++;
      }
      if (s[i]!=x||i==n) {
	sum[j]=sum1;
	j++;
	break;
      }
    }
  }
  if (s[n-1]==0) {
    sum[j]=0;
    j++;
  }

  k=2*k+1;
  int left=0,right=0,tmp,ans=0;
  for (int l=0; l<j; l+=2) {
    int next_left=l;
    int next_right=min(l+k,n);
    while (left<next_left) {
      tmp-=sum[left];
      left++;
    }
    while (right<next_right) {
      tmp+=sum[right];
      right++;
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
using namespace std;
 
struct point
{
	int x,y,h;
};
 
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n;
	point t;
	vector <point> p;
 
	cin >> n;
 
	for(int i=0;i<n;i++)
	{
		cin >> t.x >> t.y >> t.h;
		p.push_back(t);
	}
 
	for(int x=0;x<=100;x++)
	{
		for(int y=0;y<=100;y++)
		{
			int H = p[0].h + abs(p[0].x-x) + abs(p[0].y-y);
			if(p[0].h==0)
			{
				for(int i=1;i<n;i++)
				{
					if(p[i].h==0)
					{
						continue;
					}
					H = p[i].h + abs(p[i].x-x) + abs(p[i].y-y);
					break;
				}
			}
			bool ok = true;
			for(int i=0;i<n;i++)
			{
				int h = max(H-abs(p[i].x-x)-abs(p[i].y-y),0);
				if(h!=p[i].h)
				{
					ok=false;
					break;
				}
			}
			if(ok)
			{
				cout << x << ' ' << y << ' ' << H << '\n';
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
bool used[100010];
main(){
    int N,l,r;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> l >> r;
        for(int j = l;j <= r;j++){
            used[j] = 1;
        }
    }
    int cnt = 0;
    for(int i = 1;i <= 100000;i++){
        cnt += used[i];
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

result = "APPROVED"

for i in range(N):
    if not( (A[i] % 2 == 1) or ((A[i] % 2 == 0) and (A[i] % 3 == 0 or A[i] % 5 == 0)) ):
        result ="DENIED"
        break

###########　出力
print(result)

Measured memory_bytes: 3060
package main

import (
	"bytes"
	"fmt"
)

type Card struct {
	suit  rune
	value int
}

func (c Card) String() string {
	b := make([]byte, 2)
	b[0] = byte(c.suit)
	b[1] = byte('0' + c.value)
	return string(b)
}

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	cards := make([]Card, n)
	cards2 := make([]Card, n)

	for i := range cards {
		fmt.Scan(&s)
		v := s[1] - '0'
		cards[i] = Card{rune(s[0]), int(v)}
	}

	copy(cards2, cards)

	bubble(cards)
	selection(cards2)
	fmt.Println(join(cards))
	fmt.Println("Stable")
	fmt.Println(join(cards2))
	if isStable(cards2, cards) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}

func isStable(c []Card, bc []Card) bool {
	for i := range c {
		if c[i] != bc[i] {
			return false
		}
	}
	return true
}

func bubble(a []Card) {
	for i, _ := range a {
		for j := len(a) - 1; j > i; j-- {
			if a[j-1].value > a[j].value {
				a[j-1], a[j] = a[j], a[j-1]
			}
		}
	}
}

func selection(a []Card) {
	var (
		mini int
	)
	for i := range a {
		mini = i
		for j := i + 1; j < len(a); j++ {
			if a[mini].value > a[j].value {
				mini = j
			}
		}
		if mini != i {
			a[mini], a[i] = a[i], a[mini]
		}
	}
}

func join(a []Card) string {
	var buf bytes.Buffer
	for i := range a {
		if i > 0 {
			buf.WriteString(" ")
		}
		buf.WriteString(a[i].String())
	}
	return buf.String()
}



Measured memory_bytes: 1192
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val s = (1..n).map { sc.next() }
  val m = sc.nextInt()
  val t = (1..m).map { sc.next() }

  println(abc091b(n, s, m, t))
}

private fun abc091b(n: Int, s: List<String>, m: Int, t: List<String>): Int {
  val map = mutableMapOf<String, Int>()
  for (si in s) {
    if (map.containsKey(si)) {
      val c = map.get(si)!! + 1
      map.put(si, c)
    } else {
      map.put(si, 1)
    }
  }
  for (ti in t) {
    if (map.containsKey(ti)) {
      val c = map.get(ti)!! - 1
      map.put(ti, c)
    }
  }

  val ans = map.values.max()!!
  if (ans <= 0) return 0

  return ans
}


Measured memory_bytes: 29724
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;
ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main(void){
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  ll g = a[0];
  for (int i = 0; i < n - 1; i++){
    g = gcd(g, a[i + 1]);
  }
  int ok = 0;
  for (int i = 0; i < n; i++){
    if (a[i] - k >= 0 && (a[i] - k) % g == 0)
      ok = 1;
  }
  if (ok)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
    

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a1=0;
int a2=0;
int a3=0;
int a4=0;
int a5=0;
int a6=0;
int a7=0;
int a8=0;
int a9=0;
int n;
int a[100005];
int da,xiao;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]<=399)
            a1=1;
        else if(a[i]<=799)
            a2=1;
        else if(a[i]<=1199)
            a3=1;
        else if(a[i]<=1599)
            a4=1;
        else if(a[i]<=1999)
            a5=1;
        else if(a[i]<=2399)
            a6=1;
        else if(a[i]<=2799)
            a7=1;
        else if(a[i]<=3199)
            a8=1;
        else
            a9++;
    }
    int num=0;
    if(a1)
        num++;
    if(a2)
        num++;
    if(a3)
        num++;
    if(a4)
        num++;
    if(a5)
        num++;
    if(a6)
        num++;
    if(a7)
        num++;
    if(a8)
        num++;
    if(num==0)
    {
        if(a9==0)
        {
            da=0;
            xiao=0;
        }
        else
        {
            da=a9;
            xiao=1;
        }
    }
    else
    {
        da=num+a9;
        xiao=num;
    }
    printf("%d %d\n",xiao,da);
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;

ll dp[100005];
ll h[100005];
int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> h[i];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i = 3; i <= N; i++){
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]- h[i-1]));
    }
    cout << dp[N] << endl;
}



Measured memory_bytes: 1792
S=input()
ecount=0
wcount=0
ncount=0
scount=0
flag=1
for i in range(len(S)):
    if S[i]=="E":
        ecount=ecount+1
    elif S[i]=="W":
        wcount=wcount+1
    elif S[i]=="N":
        ncount=ncount+1
    else:
        scount=scount+1
if (ncount>0)or(scount>0):
    if (ncount*scount==0):
        flag=0
if (wcount>0)or(ecount>0):
    if (wcount*ecount==0):
        flag=0
if flag==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    string S; cin >> S;
    S = "0" + S;
    int N = S.size();
    auto dp = multivector(N+1,2,LOWINF);
    dp[N][0] = 0;
    for(int i = N-1; 0 <= i; --i) {
        ll c = S[i]-'0';
        chmin(dp[i][0],dp[i+1][0] + c);
        chmin(dp[i][0],dp[i+1][1] + c+1);
        chmin(dp[i][1],dp[i+1][0] + 10-c);
        chmin(dp[i][1],dp[i+1][1] + 10-(c+1));
    }
    cout << min(dp[0][0],dp[0][1]) << endl;

	

    return 0;
}

Measured memory_bytes: 55856
#include <bits/stdc++.h>
#define int long long int
#define INF (int)1e9
#define INFL (int)1e15
#define MAXN (int)1e6
#define err 1e-15
#define sz size
int getInt(char ch) {
    return (int)(ch - '0');
}
int cdiv(int num, int den) {
    return (num%den == 0) ? (num/den) : (num/den)+1;
}
using namespace std;

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

    int n;
    cin >> n;

    vector<int> h(n, 0);

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

    int ans[n];
    ans[0] = 0;

    for(int i = 1; i < n; i++) {
        if(h[i] > h[i-1]) {
            ans[i] = 0;
        }else {
            ans[i] = ans[i-1] + 1;
        }
    }

    int maxAns = -INFL;

    for(int i = 0; i < n; i++) {
        maxAns = max(maxAns, ans[i]);
    }


    cout << maxAns << endl;
    return 0;
}	

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n,k;cin>>n>>k;
  // ll p[n];rep(i,0,n)cin>>p[i];
  // set<double,greater<double>>se;
  double ans[n];
  rep(i,0,n){
    double a;cin>>a;
    ans[i]=0.5*a*(a+1)/a;
    // se.insert(0.5*a*(a+1)/a);
  }
  vector<double>s(n+1,0);
  rep(i,0,n)s[i+1]=s[i]+ans[i];

  double ma=0;
  rep(i,0,n-k+1){
    double sum=s[k+i]-s[i];
    ma=max(ma,sum);
  }
  // out(ma);
  // double ma=0;
  // // rep(i,0,n)out(ans[i]);
  // rep(i,0,n-k+1){
  //   double sum=0;
  //   rep(j,0,k)sum+=ans[i+j];
  //   ma=max(ma,sum);
  //   // ma=max(ma,ans[i]+ans[i+1]+ans[i+2]);
  // }


  cout<<setprecision(12)<<ma<<endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	string s="NO";
	if(a==5&&b==5&&c==7)s="YES";
	if(a==5&&b==7&&c==5)s="YES";
	if(a==7&&b==5&&c==5)s="YES";
	cout << s << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, y) = readIntegerList()
    for (i in 0..n) {
        for (j in 0..(n - i)) {
            val k = n - i - j
            val tmp = 10000 * i + 5000 * j + 1000 * k
            if (tmp == y) {
                println("$i $j $k")
                return
            }
        }
    }
    println("-1 -1 -1")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 37876
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(x%2==0){
            if((x%3!=0) && (x%5!=0)){
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
}

Measured memory_bytes: 256