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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    unordered_map<unsigned long, unsigned long> mp;
    unsigned long mask{random_device{}()};
    for(auto&& i : A){
        cin >> i;
        ++mp[i ^ mask];
    }
    unsigned long ans{0};
    for(const auto& i : A){
        [&]{unsigned long cnt{0};
        for(unsigned long j{1}; j * j <= i; ++j)if(i % j == 0){
            cnt += mp[j ^ mask];
            if(j * j < i)cnt += mp[(i / j) ^ mask];
            if(cnt > 1)return;
        }
        ++ans;}();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 33356
#include <iostream>
#include <cmath>

using namespace std;

int main() {

  int a, b;

  cin >> a >> b;

  int answer;

  for (int i = 10; i <= 1250; i++) {
    if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{ 
ll p=0,q=0,r=0,k=0;
 tt
 {string a="AC",b="WA",c="TLE",d="RE";
    string s;
    cin>>s;
    if(s==a) p++;
    else if(s==b) q++;
    else if(s==c) r++;
    else if(s==d) k++;

 }
 cout<<"AC x"<<" "<<p<<endl;
 cout<<"WA x"<<" "<<q<<endl;
 cout<<"TLE x"<<" "<<r<<endl;
 cout<<"RE x"<<" "<<k<<endl;
}

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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	int ar[n];
	int maxi = 0;
	for(int i = 0; i < n; i++){
		int cur;
		cin >> cur;
		maxi ^= cur;
		ar[i] = cur;
	}
	for(int i = 0; i < n; i++){
		int sol = maxi ^ ar[i];
		cout << sol << (i == n - 1 ? '\n' : ' ');
	}
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define mod 1000000007
#define inf (int)1e9+7
using namespace std;
ll dp[1009][1009];
ll h,w;
char ch[1009][1009];
ll call(ll i,ll j)
{
    if(i==h-1 and j==w-1) return 1;
    ll &ret=dp[i][j];
    if(ret!=-1) return ret;
    ll a=0,b=0;
    if(i<h-1 and ch[i+1][j]=='.') a+=call(i+1,j);
    if(j<w-1 and ch[i][j+1]=='.') b+=call(i,j+1);
    return ret=(a%mod+b%mod)%mod;
}
int   main()
{
    memset(dp,-1,sizeof dp);
        cin>>h>>w;
        for(ll i=0;i<h;i++)
        {
            for(ll j=0;j<w;j++)
            {
                cin>>ch[i][j];
            }
        }
        cout<<call(0,0)%mod<<endl;
}


Measured memory_bytes: 9216
#include<iostream>
using namespace std;
int main()
{
          int a[100000],c,i,j;
          for(i=0;i<5;i++)
          {
                    cin>>a[i];
          }
          for(i=0;i<5-1;i++)
          {
                    for(j=0;j<5-i-1;j++)
                    {
                              if(a[j]>a[j+1])
                              {
                                        c=a[j];
                                        a[j]=a[j+1];
                                        a[j+1]=c;
                              }
                    }
          }

                    cout<<a[4]<<" ";
                    cout<<a[3]<<" ";
                    cout<<a[2]<<" ";
                    cout<<a[1]<<" ";
                    cout<<a[0]<<"\n";
return 0;
}



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

int main(){
	string devide[4] = {"dream", "dreamer", "erase", "eraser"};
	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	for(int i=0; i<4; ++i) reverse(devide[i].begin(), devide[i].end());

	bool flag = true;
	for(int i=0; i<S.size();){
		bool flag2 = false;
		for(int j=0; j<4; ++j){
			string d = devide[j];
			if(S.substr(i, d.size())==d){
				flag2 = true;
				i += d.size();
			}
		}
		if (!flag2){
				flag = false;
				break;
			}
	}
	if (flag){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<cmath>
#include<vector>
#include<map>
#include<random>
using namespace std;

int main(){
    double t,x; cin >> t >> x;
    cout << t/x << endl;

}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

int n, m;
int a[106];
vi b;

auto ifodd = [](int x) { return x % 2 == 1; };
auto ifeven = [](int x) { return x % 2 == 0; };

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
		cin >> a[i];
	
	int odd = count_if(a, a + m, ifodd);
	if (odd > 2) {
		puts("Impossible");
		return 0;
	}
	
	if (odd == 0) {
		b.pb(1);
		for (int i = 0; i < m - 1; ++i)
			b.pb(a[i]);
		b.pb(1);
		b.pb(a[m - 1] - 2);
		
	} else if (odd == 1) {
		if (m == 1) {
			b.pb(1);
			b.pb(a[0] - 1);
		} else {
			partition(a, a + m, ifodd);
			b.pb(a[0] + 1);
			for (int i = 1; i < m - 1; ++i)
				b.pb(a[i]);
			b.pb(1);
			b.pb(a[m - 1] - 2);
		}
	} else if (odd == 2) {
		partition(a, a + m, ifodd);
		partition(a + 1, a + m, ifeven);
		b.pb(a[0] + 1);
		for (int i = 1; i < m - 1; ++i)
			b.pb(a[i]);
		b.pb(a[m - 1] - 1);
	}
	
	b.erase(remove(b.begin(), b.end(), 0), b.end());
	
	for (int i = 0; i < m; ++i)
		cout << a[i] << ' ';
	cout << endl;
	cout << b.size() << endl;
	for (auto i : b)
		cout << i << ' ';
	cout << endl;
	
	return 0;
}


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

int main() {
  long long L, R;
  cin >> L >> R;
  int mod = 2019;
  long long ans = 10000000;
  for(long long i = L; i < R && i < L+2019;i++){
    for(long long j = L+1; j <= R && j <=L+ 2019;j++){
      ans = min(ans, i*j%mod);
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main(void) {
  int h, w;
  cin >> h >> w;

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

  int cnt = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        cnt++;
      }
    }
  }

  if (cnt == h + w - 1) {
    cout << "Possible\n";
  } else {
    cout << "Impossible\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, a, mx, c[100005];
int main() {
	scanf("%d", &n);
	while(n--) scanf("%d", &a), c[a]++;
	for(int i=1; i<=100000; i++) mx = max(mx, c[i-1] + c[i] +c[i+1]);
	cout<<mx;
	return 0;
}

Measured memory_bytes: 640
# coding: utf-8
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')
else:
    print('No')

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const string YES = "Yes";
V<V<int> > m;

void solve(int N, int M){
	V<int> ans(N+1);
	queue<int> q;
	q.push(1);
	int tmp,n;
	while(!q.empty()) {
		n = q.front();
		q.pop();
		REP(i,m[n].size()) {
			tmp = m[n][i];
			if(ans[tmp] == 0) {
				ans[tmp] = n;
				q.push(tmp);
			}
		}
	}	
	cout << "Yes" << endl;
	FOR(i,2,N+1) {
		cout << ans[i] << endl;
	}

}

int main(){
    int N,M;
	cin >> N >> M;
	REP(i,N+1) {
		V<int> a;
		m.push_back(a);
	}

	int a,b;
    for(int i = 0 ; i < M ; i++){
		cin >> a >> b;
		m[a].push_back(b);
		m[b].push_back(a);
    }
    solve(N, M);
    return 0;
}



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

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;
	vector<long long> sum(1,0);
	for(int i=0;i<N;i++)sum.push_back(sum[i]+A[i]);
	
	long long ans=99999999999999999LL;
	
	for(int i=1;i<N;i++)ans=min(ans,abs(sum[i]-(sum[N]-sum[i])));
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while(true){
		a -= d;
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		if(a <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
n = int(input())

c = 0

for i in range(25):
	for j in range(15):
		if i*4+j*7 == n:
			c += 1
	
		if i*4+j*7 >100:
			break
  
if c != 0:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N;
	cin >> N;

	vector<Int> L(N);
	for (Int i = 0; i < N; i++) {
		cin >> L[i];
	}

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

	Int ans = 0;
	Int temp;
	for (Int i = N - 1; i >= 0; i--) {//最大辺
		for (Int j = 0; j < i - 1; j++) {//最小辺
			temp = lower_bound(L.begin(), L.end(), L[i] - L[j] + 1) - L.begin();
			temp = max(temp, j+1);
			ans += max(0LL, i-temp);
		}
	}

	cout << ans << "\n";
}


Measured memory_bytes: 256
x , n = map(int , input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int , input().split()))

ans = x

for i in range(101):
    tmp1 = x - i
    tmp2 = x + i
    if not tmp1 in p:
        ans = tmp1
        break
    elif not tmp2 in p:
        ans = tmp2
        break

print(ans)

Measured memory_bytes: 61856
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <iomanip>

using namespace std;

typedef complex<double> Point;
#define rep(i, n) for(int i=0; i<(n); ++i)
const double eps = 1e-8, inf = 1e8, pi = acos(-1.);

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

inline double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
    return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > eps)return 1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)return 2;
    if(norm(b) < norm(c))return -2;
    return 0;
}

struct Line : vector<Point> {
    Line(const Point& a, const Point& b){
        push_back(a); push_back(b);
    }
};

inline Point proj(const Line& l, const Point& p){
    double t = dot(p - l[0], l[1] - l[0]) / norm(l[0] - l[1]);
    return l[0] + (l[1] - l[0]) * t;
}

inline bool interSP(const Line& s, const Point& p){
    return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < eps;
}

inline bool interSS(const Line& s, const Line& t){
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
           ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

inline double distSP(const Line& s, const Point& p){
    const Point r = proj(s, p);
    return interSP(s, r)? abs(r - p): min(abs(s[0] - p), abs(s[1] - p));
}

inline double distSS(const Line& s, const Line& t){
    return interSS(s, t)? 0: min(min(distSP(s, t[0]), distSP(s, t[1])), min(distSP(t, s[0]), distSP(t, s[1])));
}

int N, M, L;

double solve(vector<vector<Line> >& pent){
    vector<vector<double> > dist(N, vector<double>(N));
    rep(i, N)rep(j, i){
        dist[i][j] = inf;
        rep(k, 5)rep(l, 5)chmin(dist[i][j], distSS(pent[i][k], pent[j][l]));
        dist[j][i] = dist[i][j];
    }
    rep(k, N)rep(i, N)rep(j, N)chmin(dist[i][j], dist[i][k] + dist[k][j]);
    return dist[M][L];
}

int main(){
    while(cin >> N >> M >> L, N|M|L){
        M--; L--;
        vector<vector<Line> > pent(N);
        rep(i, N){
            int x, y, a, r;
            cin >> x >> y >> a >> r;
            vector<Point> v;
            rep(j, 5)v.push_back(Point(x, y) + polar(1. * r, (a + 72 * j + 90) * pi / 180));
            rep(j, 5)pent[i].emplace_back(v[j], v[(j + 2) % 5]);
        }
        cout << fixed << setprecision(20) << solve(pent) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1436
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct string_table {
	string s;
	int n, LOG_N;
	vector<vector<int>> type;
	string_table(string& s) {
		this->s = s;
		n = s.length();
		int tmp = n; LOG_N = 1;
		while (tmp)
			tmp >>= 1, ++LOG_N;
		type.resize(n, vector<int>(LOG_N));
		for (int i = 0; i < n; ++i) {
			if (s[i] == 'A') type[i][0] = 0;
			else type[i][0] = 1;
		}
		for (int j = 1; j < LOG_N; ++j) {
			for (int i = 0; i < n; ++i) {
				int l = type[i][j - 1], r = type[min(n - 1, i + (1 << (j - 1)))][j - 1];
				if (l == 2) type[i][j] = r;
				else if (r == 2) type[i][j] = l;
				else if (l == 0) type[i][j] = r + 1;
				else if (l == 1) type[i][j] = (r + 2) % 3;
			}
		}
	}
	int get_type(int a, int b) {
		--a;
		int res = 2;
		for (int j = LOG_N - 1; j >= 0; --j) {
			if ((b - a) & (1 << j)) {
				int right = type[a][j];
				if (res == 2) res = right;
				else if (right == 2) res = res;
				else if (res == 0) res = right + 1;
				else if (res == 1) res = (right + 2) % 3;
				a += (1 << j);
			}
		}
		return res;
	}
};

int main() {
	string s;  cin >> s;
	string_table sts(s);
	string t; cin >> t;
	string_table stt(t);
	int q; cin >> q;
	while (q--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if (sts.get_type(a, b) == stt.get_type(c, d))
			cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 21248
use proconio::{input, fastout};

struct UnionFind {
    par: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> Self {
        let mut par = Vec::new();

        for i in 0..n {
            par.push(i);
        }

        Self { par }
    }

    fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {return x;}
        self.par[x] = self.root(self.par[x]);
        self.par[x]
    }

    fn union(&mut self, x: usize, y: usize) {
        let rx = self.root(x);
        let ry = self.root(y);

        if rx == ry {return;}

        self.par[rx] = ry;
    }

 //   fn same(&mut self, x: usize, y: usize) -> bool {
 //       self.root(x) == self.root(y)
 //   }

    fn greate(&mut self) -> usize {
        let mut counts = vec![0usize; self.par.len()];
        
        for i in 0..self.par.len() {
            self.root(i);
        }
        for &i in self.par.iter() {
            counts[i] += 1;
        }

        *counts.iter().max().unwrap()
    }
}
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize, usize); m],
    };

    let mut union = UnionFind::new(n);

    for i in ab {
        union.union(i.0-1, i.1-1);
    }

    //println!("{:?}", union.par);
    println!("{}", union.greate());
}


Measured memory_bytes: 12516
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()

using namespace std;
typedef long long ll;

int main()
{
  int N, H; cin >> N >> H;
  vector<int> a(N), b(N);
  REP(i, N) cin >> a[i] >> b[i];
  int ama = -1;
  REP(i, N) ama = max(ama, a[i]);

  sort(ALL(b));
  int bidx = upper_bound(ALL(b), ama) - b.begin();

  int ans = 0;
  for (int i = N - 1; i >= bidx; i--) {
    H -= b[i];
    ans++;
    if (H <= 0) break;
  }
  if (H > 0) ans += (H + ama - 1) / ama;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int r, c;

  scanf("%d %d", &r, &c);

  while( !(r == 0 && c == 0) ) {
    if ( r*c % 2 == 0)
      printf("yes\n");
    else 
      printf("no\n");
    scanf("%d %d", &r, &c);

  }

  return 0;

}

Measured memory_bytes: 580
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <atcoder/all>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using namespace atcoder;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const int INF = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 100005;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    cin >> t;
    rep(i,t){
        ll n,m,a,b;
        cin >> n >> m >> a >> b;
        PRINT(floor_sum(n,m,a,b));
    }
}


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

int main(){
    int k;
    string s;
    cin >> s >> k;
    set<string> a;
    for(int i = 1; i <= k; i++){
        for(int j = 0; j < s.size()-i+1; j++){
            a.insert(s.substr(j, i));
        }
    }
    auto itr = a.begin();
    advance(itr, k-1);
    cout << *itr << endl; 
    return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
int n;
int dp[200000][3];
vector<vector<int> > v(200000);
int f(int x,int y)
{
	if(x==n)
		return 0;
	if(dp[x][y]!=-1)
		return dp[x][y];
	if(y==0)
		return dp[x][y]=max(v[x][1]+f(x+1,1),v[x][2]+f(x+1,2));
	if(y==1)
		return dp[x][y]=max(v[x][0]+f(x+1,0),v[x][2]+f(x+1,2));
	if(y==2)
		return dp[x][y]=max(v[x][0]+f(x+1,0),v[x][1]+f(x+1,1));
}
int32_t  main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			int x;
			cin>>x;
			v[i].push_back(x);
		}
	}
	cout<<max({v[0][0]+f(1,0),v[0][1]+f(1,1),v[0][2]+f(1,2)})<<endl;
	return 0;
}

Measured memory_bytes: 18944
//package code;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author Milo
 */
public class Main {
    
    static FastReader in = new FastReader();
    public static void main(String[] args) {
        int t = 1; //in.nextInt();
        while (t-- > 0)
            solve();
    }
 
    public static void solve() {
        int n = in.nextInt();
        int s[] = new int[n];
        int k = in.nextInt();
        
        for(int i = 0; i < k; ++i){
            int d = in.nextInt();
            for(int f = 0; f < d; ++f){
                int b = in.nextInt();
                ++s[--b];
            }
        }
        int ans = 0;
        for(int a : s){
            if(a == 0) ++ans;
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static int max(int a, int b) {
        return a > b ? a : b;
    }
 
    public static int min(int a, int b) {
        return a < b ? a : b;
    }
 
    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, (a % b));
    }
}


Measured memory_bytes: 33196
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
	return 0;
}

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

struct Point {double x,y;};

inline void koch(int n, Point a, Point b){
	if(n==0) return;
	Point s, t, u;
	double th = M_PI*60.0/180.0;

	s.x = (2.0*a.x + 1.0*b.x)/3.0;
	s.y = (2.0*a.y + 1.0*b.y)/3.0;
	t.x = (1.0*a.x + 2.0*b.x)/3.0;
	t.y = (1.0*a.y + 2.0*b.y)/3.0;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(n-1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n-1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n-1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n-1, t, b);
}


int main() {
	//ios::sync_with_stdio(false);
	Point a,b;
	int n;

	scanf("%d", &n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll x, y;
  cin >> x >> y;
  int ans = 0;
  while (x <= y) {
    ans++;
    x *= 2;
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  double count = 0;
  for(int i=0; i<n; i++){
    double num;
    cin >> num;
    double reverse = 1/num;
    count += reverse;
  }
  cout << setprecision(10) << 1/count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
const int INFN = 1e9+7;
const int MAXK = 3;
const int MAXN = 1e5+5;
std::vector<int> G[MAXN];
int D[MAXN][MAXK];
int M, N, S, T;

struct Pair {
  int node, state;
};

int solve() {
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < MAXK; ++j) {
      D[i][j] = INFN;
    }
  }
  std::queue<Pair> Q;
  D[S][0] = 0;
  Q.push(Pair{S, 0});
  while (!Q.empty()) {
    Pair cur = Q.front();
    Q.pop();
    int nst = (cur.state + 1) % MAXK;
    for (int nxt: G[cur.node]) {
      if (D[nxt][nst] == INFN) {
        D[nxt][nst] = D[cur.node][cur.state] + 1;
        Q.push(Pair{nxt, nst});
      }
    }
  }
  if (D[T][0] == INFN) {
    D[T][0] = -1;
  } else {
    D[T][0] /= MAXK;
  }
  return D[T][0];
}

int main() {
  scanf(" %d%d", &N, &M);
  for (int i = 0; i < M; ++i) {
    int u, v;
    scanf(" %d%d", &u, &v);
    G[u].push_back(v);
  }
  scanf(" %d%d", &S, &T);
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code

    int n;
    cin >> n;
    set<string> s;
    rep(i, n) {
        string a;
        cin >> a;
        s.insert(a);
    }
    output(s.size());
    
    return 0;
}


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

int main()
{
    ll n, k, score = 0;
    string s;
    cin >> n >> k >> s;
    rep(i, n - 1)
    {
        if (s[i] == s[i + 1])
            score++;
    }
    int ans = min(score + 2 * k, n - 1);
    // cout << ans << endl;
    // char c = s[0];
    // rep(i, n)
    // {
    //     if (s[i] != c && k > 0){
    //         while(){
    //             s[]
    //         }
    //     }
    // }
    // rep(i, n)
    // {
    //     if (i == 0 && s[i] == 'L')
    //         continue;
    //     if (i == n - 1 && s[i] == 'R')
    //         continue;
    //     if (s[i] == 'R' && s[i + 1] == 'R')
    //         ans++;
    //     if (s[i] == 'L' && s[i - 1] == 'L')
    //         ans++;
    // }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3728
H, W, N = [int(v) for v in input().split()]
points = (map(int, input().split()) for _ in range(N))
memory = {}
for ai, bi in points:
    for i in range(max(2, ai - 1), min(H - 1, ai + 1) + 1):
        for j in range(max(2, bi - 1), min(W - 1, bi + 1) + 1):
            key = (i, j)
            if not key in memory:
                memory[key] = 0
            memory[key] += 1

counter = {i: 0 for i in range(1, 10)}
for v in memory.values():
    counter[v] += 1

print((H - 2) * (W - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])


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

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<int> t(N);
    for (int i = 0; i < N; i++) t[i] = (int)(s[i]-'1');
    if (N%2 == 0) {
        N--;
        for (int i = 0; i < N; i++) t[i] = abs(t[i]-t[i+1]);
        t.resize(N);
    }
    
    if (count(t.begin(), t.end(), 1) == 0) {
        ll x = 0;
        for (int i = 0; i < N; i++) {
            if (((N-1)&i) == i && t[i] == 2) x += 1;
        }
        if (x%2 == 1) cout << 2 << endl;
        else cout << 0 << endl;
        return 0;
    }else {
        ll x = 0;
        for (int i = 0; i < N; i++) {
            if (((N-1)&i) == i && t[i] == 1) x += 1;
        }
        if (x%2 == 1) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 5252
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re

def main():
    ID_gate = re.split(" +", input())
    ID = ID_gate[0]
    gate = ID_gate[1]
    min = 0
    max = 1000000
    for n in range(int(gate)):
        l_r = re.split(" +", input())
        if min < int(l_r[0]):
            min = int(l_r[0])
        if int(l_r[1]) < max:
            max = int(l_r[1])
    if max - min + 1 < 0:
        print(0)
    else:
        print(max - min + 1)

if __name__ == "__main__":
    main() 


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	string A = "CODEFESTIVAL2016";
	int ans = 0;
	F0R(i, S.size()) {
		ans += A[i] != S[i];
	}
	print(ans);
}

Measured memory_bytes: 3580
/*
 
dunjen_master
 
*/
 
 
 
 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()
 
/* ordered_set A;
   A.insert(x);
   A.erase(x);
   A.order_of_key(x) // no of elements less than (<) x
   *A.find_by_order(k-1) // kth smallest element
*/
// int n;
// ll dp[200005][205];
// ll ans=0;
// int a[200005];
// int req;
// ll neg=-1e15;
 
 
// ll fun(int indx,int last){
//    // cout<<indx<<" "<<last<<" "<<req<<endl;
//     if(indx==n){
//         if(last==req){
//             return 0;
//         }else{
//             return neg;
//         }
//     }
 
//     if(dp[indx][last]!=-1){
//         return dp[indx][last];
//     }
    
//     ll ans=neg;
 
//     ans=max(ans,fun(indx+1,last));
 
//     if(last==0)ans=max(ans,1+fun(indx+1,a[indx]));
//     if(last==a[indx])ans=max(ans,1+fun(indx+1,a[indx]));
//     if(a[indx]==req)ans=max(ans,1+fun(indx+1,a[indx]));
 
//     return dp[indx][last]=ans;
 
 
// }

int n;
ll a[200005];
ll ans[200005];
vector<int>v[200005];

void fun(){

    for(int i=0;i<n;i++){
        v[i].clear();
    }

    for(int i=0;i<n;i++){
        if(i+a[i]<n)v[i+a[i]].push_back(i);
    }

    map<int,int>mp;
    int c=0;

    for(int i=n-1;i>=0;i--){
        for(auto it:v[i]){
            ans[it]=mp[c];
        }
        mp[c+a[i]]++;
        c++;
    }
}

 
int main(){

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

    fun();

    ll ans22=0;

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

    cout<<ans22;

return 0;

 
 
    
 
    
 
    
 
 
 
 
 
 
 
 
 
   
 
 
 
    
    
 
    
 
    
 
  
    
 
 
 
    
 
 
    
    
    
    
 
    
}


Measured memory_bytes: 23524
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define N 400005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
LL c[N],w[N],col[N];
LL n,x,y,cnt;
vector<LL>a[N];
LL fac[N],ifac[N];
LL ksm(LL a,LL b)
{
	LL ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%lld %lld %lld",&n,&x,&y);
	LL mminw=INF;
	int minc;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&c[i],&w[i]);
		a[c[i]].push_back(i);
		if(w[i]<mminw)
		{
			mminw=w[i];
			minc=c[i];	
		}
	}
	LL mminw1=INF;
	for(int i=1;i<=n;i++)
	{
		LL minw=INF;
		for(int j=0;j<a[i].size();j++)	
			minw=min(minw,w[a[i][j]]);
		for(int j=0;j<a[i].size();j++)
			if(w[a[i][j]]+minw<=x)
				w[a[i][j]]=minw;
		if(minc!=i)
			mminw1=min(mminw1,minw);
	}
	for(int i=1;i<=n;i++)
	{
		if(c[i]==minc)
		{
			if(w[i]+mminw1<=y)
			{
				col[c[i]]++;
				cnt++;	
			}
		}
		else if(w[i]+mminw<=y)
		{
			col[c[i]]++;
			cnt++;
		}
	}
	fac[0]=1;
	for(int i=1;i<=cnt;i++)
		fac[i]=fac[i-1]*i%MOD;
	ifac[cnt]=ksm(fac[cnt],MOD-2);
	for(int i=cnt;i>=1;i--)
		ifac[i-1]=ifac[i]*i%MOD;
	LL ans=fac[cnt];
	for(int i=1;i<=n;i++)
		ans=ans*ifac[col[i]]%MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 28800
#include <iostream>
#include <cmath>
#include <cstdio>

#define H 31
#define W 31
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

inline void remove(int game[H][W], int pt_h, int pt_w){
  game[pt_h][pt_w] = -1;
}

inline void move(int game[H][W], int h, int w){
  //-1 means it is deleted space.

  for(int j=0; j<w; j++){
    for(int i=h-1; i>0; i--){
      if(game[i][j] == -1){
	int k = i-1;
	while(true){
	  if(game[k][j]==-1 and k>0) k--;
	  else                       break;
	}
	std::swap(game[i][j], game[k][j]);
      }
    }
  }
}

inline void print(int game[H][W], int h, int w){
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      std::cout << " " << game[i][j];
    }
    std::cout << std::endl;
  }
}

inline int earn(int game[H][W], int h, int w, int k, int num_step){
  int earn_score = 0;
  int now = -1, count = 0;
  for(int i=0; i<h; i++){
    now = -1, count = 0;
    for(int j=0; j<w; j++){
      if(game[i][j] != now){
	if(count >= k and now != -1){
	  for(int tmp=0; tmp<count; tmp++){
	    remove(game,i,j-tmp-1);
	  }
	  earn_score += std::pow(2, num_step)*now*count;
	}
	now = game[i][j];
	count = 1;
      }else{
	count++;
      }
    }
    if(count >= k and now != -1){
      for(int tmp=0; tmp<count; tmp++){
	remove(game,i,w-1-tmp);
      }
      earn_score += std::pow(2, num_step)*now*count;
    }

  }
  //print(game, h, w);
  //std::cout << num_step << " " << earn_score << std::endl;
  return earn_score;
}


int calcScore(const int c_game[H][W], int h, int w, int erase_w, int erase_h, int k){
  int score = 0;
  int next_score = 0;
  int step = 0;
  int game[H][W];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      game[i][j] = c_game[i][j];
    }
  }
  remove(game, erase_h, erase_w);
  move(game, h, w);
  next_score = earn(game, h, w, k, step);
  step++;
  score += next_score;
  while(next_score){
    move(game, h,w);
    next_score = earn(game, h, w, k, step);
    step++;
    score += next_score;
  }
  //std::cout << std::endl;
  return score;
}

int main(void){
  int h,w,k;
  std::cin >> h >> w >> k;

  
  int game[H][W];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      scanf("%1d", &game[i][j]);
    }
  }
  int max = 0;
  for(int j=0; j<w; j++){
    for(int i=0; i<h; i++){
      int score = calcScore(game, h, w, j, i, k);
      //std::cout << j << " " << score << std::endl;
      if(score > max){
	max = score;
      }
    }
  }
  std::cout << max << std::endl;
  return 0;
}

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

void solve() {
  int k; cin >> k;
  while(k--) cout << "ACL";
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <memory.h>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int maxn = 100010;

ll dist[maxn];
vector<P> G[maxn];

vector<ll> bfs(){
  queue<ll> que;
  vector<ll> res;
  memset(dist, -1, sizeof(dist));
  dist[0] = 0;
  que.push(0);
  
  while(!que.empty()){
    int v = que.front(); que.pop();
    rep(i, (int)G[v].size()){
      int to = G[v][i].first;
      ll cost = G[v][i].second;
      if(dist[to] == -1){
	dist[to] = dist[v] ^ cost;
	que.push(to);
      }else{
	if(dist[to] ^ dist[v] ^ cost) res.push_back(dist[to] ^ dist[v] ^ cost);
      }
    }
  }
  return res;
}

vector<ll> collect(vector<ll> cycle){
  int n = cycle.size();
  vector<ll> res(60, 0);
  for(int i = 59; i >= 0; i--){
    rep(j, n){
      if((cycle[j] >> i) & 1){
	res[i] = cycle[j];
	rep(k, n){
	  if(k != j && ((cycle[k] >> i) & 1)) cycle[k] ^= cycle[j];
	}
	cycle[j] = 0;
	break;
      }
    }
  }
  return res;
}

ll calc(ll res, const vector<ll> &base){
  for(int i = 59; i >= 0; i--){
    if(((base[i] ^ res) >> i) & 1) res ^= base[i]; 
  }
  return res;
}

int main(){
  ll N, M, Q, a, b, f, t, p;
  
  cin >> N >> M >> Q;
  rep(i, M) {
    cin >> f >> t >> p;
    G[f].push_back(P(t, p));
    G[t].push_back(P(f, p));
  }
  
  vector<ll> cycle = bfs();
  vector<ll> base = collect(cycle);
  
  rep(i, Q){
    cin >> a >> b;
    cout << calc(dist[a] ^ dist[b], base) << endl;
  }
  return 0;
}

Measured memory_bytes: 15060
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, K, num = 0;
  cin >> N >> K;
  int a, b;
  cin >> a;
  num = max(num, a);
  for(int i = 1; i < N; i++){
    cin >> b;
    num = max(num, b);
    a = __gcd(a, b);
  }
  if(num >= K && K % a == 0)cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ALDS1_3_C
{
	class Program
	{
		static void Main(string[] args)
		{
			LinkedList<string> list = new LinkedList<string>();
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++)
			{
				string[] s = Console.ReadLine().Split();
				switch (s[0])
				{
					case "insert":
					{
						list.AddFirst(s[1]);
						break;
					}
					case "delete":
					{
						//if (list.Contains(s[1])) 
						list.Remove(s[1]);
						break;
					}
					case "deleteFirst":
					{
						list.RemoveFirst();
						break;
					}
					case "deleteLast":
					{
						list.RemoveLast();
						break;
					}
				}
			}
			Console.WriteLine(string.Join(" ", list));
		}
	}
}


Measured memory_bytes: 120996
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(!(b-a&1ll))printf("%lld\n",b-a>>1);
	else printf("%lld\n",min(a-1ll,n-b)+(b-a+1ll>>1));
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int lower = max(a, c);
  int upper = min (b, d);
  int ans = max(0, upper - lower);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  ll N; cin >> N;
  ll a, b, c, d, e; cin >> a >> b >> c >> d >> e;
  ll m = min({a,b,c,d,e});
  ll retval = (N+m-1ll)/m + 4ll;
  cout << retval << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}



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

int main() {
    int n;
    string s,t;
    cin >> n >> s >> t;

    rep(i,n) {
        cout << s.at(i) << t.at(i);
    }

    printf("\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool a = false;
  for(int i = 0; i <= B - A; i++) {
    if((A + i) % K == 0) {
      a = true;
      break;
    }
  }
  if(a)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}

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

using namespace std;

const int md = 1e9 + 7;

void add(int& a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  vector< vector<int> > g(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &g[i][j]);
    }
  }
  vector<int> dp(1 << n);
  dp[(1 << n) - 1] = 1;
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < (1 << n); t++) {
      int u = t;
      while (u > 0) {
        int j = __builtin_ctz(u & -u);
        if (g[i][j]) {
          add(dp[t ^ (1 << j)], dp[t]);
        }
        u -= u & -u;
      }
      dp[t] = 0;
    }
  }
  printf("%d\n", dp[0]);
  return 0;
}


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

int get_root(int i, int wood[])
{
    // depth = 0;
    while (wood[i] != i)
    {
        wood[i];
        i = wood[i];
        // depth++;
    }
    return i;
}

int main()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    int wood[n];
    int depth[n]{1};
    rep(i, n) wood[i] = i;
    int a, b;
    int ra, rb;
    int friends[n] = {0};
    rep(i, m)
    {
        scanf("%d%d", &a, &b);
        a--;
        b--;
        friends[a]++;
        friends[b]++;
        ra = get_root(a, wood);
        rb = get_root(b, wood);
        if (depth[ra] > depth[rb])
            swap(ra, rb);
        depth[rb] = depth[rb] > depth[ra] + 1 ? depth[rb] : depth[ra] + 1;
        wood[ra] = rb;
    }
    int group_num[n] = {0};
    rep(i, n)
    {
        int idx = get_root(i, wood);
        group_num[idx]++;
    }
    int ans[n] = {0};
    rep(i, k)
    {
        scanf("%d%d", &a, &b);
        a--;
        b--;
        if (get_root(a, wood) == get_root(b, wood))
        {
            ans[a]--;
            ans[b]--;
        }
    }
    rep(i, n)
    {
        printf("%d ", ans[i] + group_num[get_root(i, wood)] - friends[i] - 1);
    }
    printf("\n");
}

Measured memory_bytes: 2816
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m, k = map(int, input().split())
    from collections import deque
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    a, b = [0], [0]
    for i in range(n):
        a.append(a[i]+A[i])
    for i in range(m):
        b.append(b[i]+B[i])
    
    ans, j = 0, m
    for i in range(n+1):
        if a[i] > k:
            break
        while b[j] > k - a[i]:
            j -= 1
        ans = max(ans, i+j)        
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 47852
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define VV(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n; cin >> n;
	vll v(n); rep(i, 0, n) cin >> v[i];
	cout << *min_element(all(v)) << " " <<
			*max_element(all(v)) << " " <<
			accumulate(all(v), 0LL) << endl;
	return 0;
}

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

int main(){

  vector<int> A(3);
  
  for(int i=0; i<3; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A[2]*10+A[1]+A[0] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
map<string, string> weather;
int main() {
    weather["Sunny"] = "Cloudy";
    weather["Cloudy"] = "Rainy";
    weather["Rainy"] = "Sunny";
    string S;
    cin >> S;
    cout << weather[S] << endl;
    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
s=input()
try:
  if s[:a].isdecimal()==True and s[a+1:].isdecimal()==True:
    print("Yes" if s[:a]+"-"+s[a+1:]==s else "No")
  else:
    print("No")
except:
  print("No")


Measured memory_bytes: 2940