akhauriyash/Code-Regression huggingface dataset:
/*
			███╗   ███╗ █████╗ ███████╗███╗   ███╗ ██████╗ ██╗   ██╗██████╗ ███████╗ █████╗ ███╗   ███╗██████╗ ██╗   ██╗
			████╗ ████║██╔══██╗╚════██║████╗ ████║██╔═══██╗██║   ██║██╔══██╗╚════██║██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝
			██╔████╔██║███████║    ██╔╝██╔████╔██║██║   ██║██║   ██║██║  ██║    ██╔╝███████║██╔████╔██║██║  ██║ ╚████╔╝
			██║╚██╔╝██║██╔══██║   ██╔╝ ██║╚██╔╝██║██║   ██║██║   ██║██║  ██║   ██╔╝ ██╔══██║██║╚██╔╝██║██║  ██║  ╚██╔╝
			██║ ╚═╝ ██║██║  ██║   ██║  ██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██████╔╝██╗██║  ██║  ██║██║ ╚═╝ ██║██████╔╝   ██║
			╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝  ╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝╚═╝  ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝    ╚═╝

			“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define pb push_back
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define un_map unordered_map
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define scll(x) scanf("%I64d", &x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define pr(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const ll mod = 1000000007;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const int N = 1e5 + 1;
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
int n, k;
int mem[N];
vector<int>v;
int solve(int i) {
	int& ret = mem[i];
	if (~ret)return ret;
	ret = Mx;
	if (i + 1 < n)
		ret = min(ret, solve(i + 1) + abs(v[i] - v[i + 1]));
	if (i + 2 < n)
		ret = min(ret, solve(i + 2) + abs(v[i] - v[i + 2]));
	ret = ret == Mx ? 0 : ret;
	return ret;
}
int main()
{
	Ma7moud_7amdy;
	//Open_Sesame;
	clr(mem, -1);
	cin >> n;
	v = vector<int>(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	cout << solve(0);
	return Accepted;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    string n;
    cin >> n;
    ll sum = 0;
    rep(i,n.size()){
        sum += n[i] - '0';
    }
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int X;
  cin >> X;
  int a = X;
  bool prime = false;
  while(true){
    if(a <= 3){
    	prime = true;
        break;
      }
  	for(int i = 2; i * i<= X; i++){
      
      if(a % i == 0){
      	prime = false;
        break;
      }
      prime = true;
    }
    
    if(prime ==true){
    	break;
    }
  	a++;
  }
    
  cout<<a<<endl;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
li = []
for i in range(b):
    li.append(input().split())
for i in range(b):
    li[i] = [int(x) for x in li[i]]
    li[i].append(i+1)
li.sort()
L = []
for i in range(a):
    L.append([])
for i in range(b):
    L[li[i][0]-1].append((li[i][0],li[i][1],li[i][2]))
ans = []
for i in range(a):
    for j in range(len(L[i])):
        ans.append((L[i][j][0],j+1,L[i][j][2]))
ans.sort(key = lambda x:x[2])
for i in range(b):
    print(str(ans[i][0]).zfill(6)+str(ans[i][1]).zfill(6))

Measured memory_bytes: 58780
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  int ans=1;
  for(int i=0;i<n;i++) {
    if(ans<=k) {
      ans *= 2;
    } else {
      ans += k;
    }
  }
  cout << ans << endl;
}

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

int main()
{
    string str;
    cin>>str;
    ll n = str.length();
    bool flg=true;
    for(ll i=0;i<n;i+=2)
        if(str[i]=='L')
            flg=false;
    for(ll i=1;i<n;i+=2)
        if(str[i]=='R')
            flg=false;

    if(flg)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
N, M, X=map(int,input().split())
A=[[0 for k in range(M+1)] for k in range(N)]
for k in range(N):
    A[k] = list(map(int, input().split()))

possible=[]


for k in range(2**N):
    bit = str(bin(k))
    count = 0
    howmuch = 0

    for l in range(1, M+1):
        for j in range(1, len(bit)-1):
            if bit[-j] == "1":
                count += A[j-1][l]
    
        if count < X:
            break
        count = 0
        

    else:
        for j in range(1, len(bit)-1):
            if bit[-j] == "1":
                howmuch += A[j-1][0]
        possible.append(howmuch)
if len(possible)>0:
    print(min(possible))
else:
    print(-1)            
            
    

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

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;
const int oo = 987654321;

int n;
int a[N];
int memo[N];

int dp(int at) {
    if(at == n) return 0;
    if(at > n) return oo;
    if(memo[at] != -1) return memo[at];
    int ans = oo;
    for(int x : {at + 1, at + 2}) {
        int cost = abs(a[at] - a[x]);
        ans = min(ans, cost + dp(x));
    }
    return memo[at] = ans;
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    memset(memo, -1, sizeof(memo));
    cout << dp(1) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	char a[4];
	int Ans = 0;
	int count = 0;

	cin >> a;
	for (int i = 0; i < 3; i++) {
		if (a[i] == 'o') { count++; }
	}

	Ans = 700 + 100 * count;

	cout << Ans;


	return 0;
}

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

using namespace std;

int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};

int main()
{
    int w, h;
    
    while (scanf("%d %d", &w, &h) && w){
        int mp[32][32] = {0};
        
        int sx, sy;
        for (int i = 1; i <= h; i++){
            for (int j = 1; j <= w; j++){
                scanf("%d", &mp[i][j]);
                if (mp[i][j] == 2){
                    sy = i; sx = j;
                    mp[i][j] = 0;
                }
            }
        }
        
        queue<pair<vector<int>, int> > q;
        
        for (q.push(make_pair(vector<int>(), sy * 32 + sx)); q.size(); q.pop()){
            int nmp[32][32];
            vector<int> nv = q.front().first;
            int ny = q.front().second / 32, nx = q.front().second % 32;
            
            if (nv.size() >= 10) continue;
            
            memcpy(nmp, mp, sizeof(mp));
            
            for (int i = 0; i < nv.size(); i++){
                nmp[nv[i] / 32][nv[i] % 32] = 0;
            }
            
            for (int i = 0; i < 4; i++){
                vector<int> tmp = nv;
                int ty = ny, tx = nx;
                int trial = 0;
                while (1){
                    ty += dy[i]; tx += dx[i];
                    if (1 > ty || ty > h || 1 > tx || tx > w) break;
                    if (nmp[ty][tx] == 1){
                        if (trial == 0) break;
                        tmp.push_back(ty * 32 + tx);
                        ty -= dy[i]; tx -= dx[i];
                        q.push(make_pair(tmp, ty * 32 + tx));
                        break;
                    }
                    if (nmp[ty][tx] == 3){
                        printf("%d\n", tmp.size() + 1);
                        goto done;
                    }
                    trial++;
                }
            }
        }
        
        printf("-1\n");
        done:;
    }
    
    return (0);
}

Measured memory_bytes: 7056
#include<iostream>

using namespace std;



int main(){
  int N, M;
  int a;
  int ans=0;
  cin >> N >> M;
  for (int i=0;i<M;i++){
    cin >> a;
    N = N - a;
    if (N < 0){
      ans = 1;
      break;
    }
  }
  if (ans==1){
    cout << -1 << endl;
  }else{
    cout << N << endl;
  }
}


Measured memory_bytes: 3164
# include<bits/stdc++.h>
# define int long long
using namespace std;
# undef int
int main()
# define int long long
{
	int a,b,c;
	cin>>a>>b>>c;
	int minn=1e9;
	minn=min(minn,abs(b-a)+abs(b-c));
	minn=min(minn,abs(b-a)+abs(a-c));
	minn=min(minn,abs(c-a)+abs(c-b));
	cout<<minn<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

// ? - '0' == 15
int A[100009]; // A[i] : (10^i)%13
ll dp[100009][13]; // dp[i][j] : i桁目まで考えて余りがj

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

	string S; cin >> S;
	reverse(S.begin(), S.end());
	A[0] = 1;
	for (int i = 1; i < S.size(); i++) A[i] = (A[i - 1] * 10) % 13;

	for (int i = 0; i < S.size(); i++) {
		int num = S[i] - '0';
		if (0 <= num && num <= 9) { // ?でなければ
			int res = (A[i] * num) % 13;

			if (i != 0) {
				for (int j = 0; j <= 12; j++) {
					dp[i][(j + res) % 13] += dp[i - 1][j];
					dp[i][(j + res) % 13] %= MOD;
				}
			}
			else {
				dp[i][res] = 1;
			}
		}
		else { // ?だったら
			for (int k = 0; k <= 9; k++) {
				int res = (A[i] * k) % 13;

				if (i != 0) {
					for (int j = 0; j <= 12; j++) {
						dp[i][(j + res) % 13] += dp[i - 1][j];
						dp[i][(j + res) % 13] %= MOD;
					}
				}
				else {
					dp[i][res] = 1;
				}
			}
		}
	}

	cout << dp[S.size() - 1][5] << endl;

	return 0;
}

Measured memory_bytes: 11088
#include<iostream>
using namespace std;
int main()
{
    long long int a,b;
    cin >> a >> b;
    if(a+b>=a-b && a+b>=a*b){
        cout << a+b ;
    }
    else if(a-b>=a+b && a-b>=a*b){
        cout << a-b;
    }
    else if(a*b>=a+b && a*b>=a-b){
        cout << a*b ;
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int X,A,B;  cin >> X >> A >> B;
    if(B-A<=0) cout << "delicious" << endl;
    else if(B-A <= X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

struct Point { double x,y; };
typedef pair<double,int> di;
typedef pair<double,double> Segment;
const int MAX_N = 2010;
const int IINF = INT_MAX;
int N;
double sx[MAX_N],sy[MAX_N],ex[MAX_N],ey[MAX_N];

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }
inline bool inside(double a,double b,double c) { return LTE(a,c) && LTE(c,b); }
inline double getDist(double x,double y) { return sqrt(x*x+y*y); }

int main(){
  cin >> N;
  vector<Segment> segs(N);
  rep(i,N) {
    cin >> sx[i] >> sy[i] >> ex[i] >> ey[i];
    vector<Point> vec(4);
    vec[0] = (Point){sx[i],sy[i]};
    vec[1] = (Point){sx[i],ey[i]};
    vec[2] = (Point){ex[i],sy[i]};
    vec[3] = (Point){ex[i],ey[i]};
    segs[i] = Segment(IINF,-IINF);
    rep(j,4){
      double arg = atan2(vec[j].y,vec[j].x) * 180 / M_PI;
      if( LT(arg,0.0) ) arg += 360;
      if( sx[i] > 0 && sy[i] < 0 && ey[i] >= 0 ) {
        if( LTE(0.0,arg) && LTE(arg,91.0) ) arg += 360;
      } 
      segs[i].first  = min(segs[i].first ,arg);
      segs[i].second = max(segs[i].second,arg);
    }
    //cout << i << " :: " << segs[i].first << "," << segs[i].second << endl;
  }

  sort(segs.begin(),segs.end());
  rep(i,N) segs.push_back(Segment(segs[i].first+360,segs[i].second+360));
  //rep(i,segs.size()) cout << i << "-th (" << segs[i].first << "," << segs[i].second << ")" << endl;
  int ans = N;
  rep(i,N){
    int cost = 0;
    double L,R;
    REP(j,i,i+N){
      cost++;
      L = segs[j].first, R = segs[j].second;
      while( j+1 < i+N && ( inside(L,R,segs[j+1].first) || inside(L,R,segs[j+1].second) ) ){
        j++;
        L = max(L,segs[j].first);
        R = min(R,segs[j].second);
        //cout << "[" << L << "," << R << "]" << endl;
      }
    }
    ans = min(ans,cost);
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1476
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i = sx; i < tx; i++){
        cout << "R";
    }
    for(int i = sy; i < ty; i++){
        cout << "U";
    }
    for(int i = sx; i < tx; i++){
        cout << "L";
    }
    for(int i = sy; i < ty; i++){
        cout << "D";
    }
    cout << "D";
    for(int i = sx; i < tx + 1; i++){
        cout << "R";
    }
    for(int i = sy; i < ty + 1; i++){
        cout << "U";
    }
    cout << "L";
    cout << "U";
    for(int i = sx; i < tx + 1; i++){
        cout << "L";
    }
    for(int i = sy; i < ty + 1; i++){
        cout << "D";
    }
    cout << "R" << endl;
}


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

using namespace std;

int main()
{
	int h;

	while (scanf("%d", &h), h){
		vector<vector<int> > v;

		v.resize(h);

		for (int i = 0; i < h; i++){
			v[i].resize(5);
		}

		for (int i = 0; i < h; i++){
			for (int j = 0; j < 5; j++){
				scanf("%d", &v[i][j]);
			}
		}

		int sum = 0;
		bool nico = true;

		while (nico){
			nico = false;

			for (int i = 0; i < h; i++){
				int flag = 0;
				int pos = 0;

				for (int j = 1; j < 5; j++){
					if (v[i][j - 1] == v[i][j] && v[i][j] != 0){
						flag++;
					}
					else if (flag > 1){
						break;
					}
					else {
						flag = 0;
						pos = j;
					}
				}

				if (flag > 1){
					for (int j = pos; j <= pos + flag; j++){
						sum += v[i][j];
						v[i][j] = 0;
					}

					nico = true;
				}
			}

			for (int i = h - 1; i > 0; i--){
				for (int j = 0; j < 5; j++){
					if (v[i][j] == 0){
						int k = i - 1;

						while (v[k][j] == 0 && k > 0){
							k--;
						}

						v[i][j] = v[k][j];
						v[k][j] = 0;
					}
				}
			}
		}

		printf("%d\n", sum);
	}

	return (0);
}

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

long long A, B, C, D;

long long getNonDividorCount(long long num, long long dividor) {
	if (dividor == 0) return -1;
	return num / dividor;
}

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

int main(){
	cin >> A >> B >> C >> D;

	long long cntC = getNonDividorCount(B, C) - getNonDividorCount(A-1, C);
	long long cntD = getNonDividorCount(B, D) - getNonDividorCount(A-1, D);
	long long lcm = C * D / gcd(C, D);
	long long cntCD= getNonDividorCount(B, lcm) - getNonDividorCount(A-1, lcm);
	
	cout << (B - A + 1 - cntC - cntD + cntCD);
	cin >> cntC;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int>a(n+1,0);
  for(int i=0; i<n-1; i++){
    int b;
    cin >> b;
    a.at(b)++;
  }
  for(int i=1; i<=n; i++){
    cout << a.at(i) << endl;
  }
}



Measured memory_bytes: 3980
n = int(input())
X = list(map(int,input().split()))

delta = [X[i+1] - X[i] for i in range(n-1)]
mod = 10**9 + 7

mother = 1
for i in range(1,n):
    mother *= i
    if mother > mod:mother %= mod

total = 0
ans = 0
for i in range(n-1):
    now = (total*pow(i+1,mod-2,mod) + 1)%mod
    ans += now*delta[i]%mod
    if ans > mod: ans %= mod
    total += now
print(ans*mother%mod)


Measured memory_bytes: 20132
let n=Int(readLine()!)!
let a=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let b=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let c=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

//let fil = a.filter { a.contains($0+1) }
var fil : [Int] = []
let sumb =  b.reduce(0, combine: +)
//let filc = c.filter { c[fil[$0]] }
var filc = 0
var i = 0
for i in 0..<a.count - 1 {
  if( a[i+1] - 1 == a[i] ) {
    fil.append(a[i])
  }
}

var j = 0
for j in 0..<fil.count {
  filc += c[fil[j] - 1]
}
  
print( sumb + filc )

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
long long n, m;

long long gcd(long long a, long long b) {
    if(a < b) {
        long long tmp = a;
        a = b;
        b = tmp;
    }
    long long r = a % b;

    while(r > 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long lcm(long long a, long long b) {
    long long g = gcd(a, b);
    long long l = a * (b / g);
    return l;
}

int main() {
    cin >> n >> m;
    vector<long long> a(n, 0);
    vector<long long> ans;
    for(int i = 0; i < n; ++i) cin >> a.at(i);
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    int alen = a.size();

    bool even = true;
    for(int i = 0; i < alen; ++i) a.at(i) /= 2;
    ans = a;
    for(int i = 0; i < alen; ++i) {
        if(a.at(i) % 2 != 0) {
            even = false;
            break;
        }
    }
    while(even) {
        for(int i = 0; i < alen; ++i) a.at(i) /= 2;
        for(int i = 0; i < alen; ++i) {
            if(a.at(i) % 2 != 0) {
                even = false;
                break;
            }
        }
    }

    bool core = true;
    for(int i = 0; i < alen; ++i) {
        if(a.at(i) % 2 == 0) {
            core = false;
            break;
        }
    }

    long long cnt = 0;
    if(core) {
        long long lc = 1;
        for(int i = 0; i < alen; ++i) {
            lc = lcm(lc, ans.at(i));
        }

        cnt = m/lc;
        cnt = (cnt+1)/2;
    }

    cout << cnt << endl;

}


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

typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
inline int in() {int x; cin >> x; return x;}

void solve() {
  int n = in(), k = in();
  int r = in(), s = in(), p = in();
  string t; cin >> t;
  vi win(n, 0);

  int ans = 0;
  FOR (i,0,n) {
    if (i>=k && t[i-k]==t[i] && win[i-k]) continue;

    if (t[i]=='r') ans+=p;
    if (t[i]=='s') ans+=r;
    if (t[i]=='p') ans+=s;

    win[i] = 1;
  }

  cout << ans << endl;
}

#undef int
int main() {
  solve();
}

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

void solve() {

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int sum = 0;
	while (k > 0 && a > 0) {
		sum++;
		a--;
		k--;
	}
	while (k > 0 && b > 0) {
		b--;
		k--;
	}
	while (k > 0 && c > 0) {
		sum--;
		c--;
		k--;
	}
	cout << sum;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif
	solve();
	return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ');
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);
        var a = Console.ReadLine().Split(' ');

        var list = new PriorityQueue<double>();
        for (var i = 0; i < n; i++)
        {
            list.Push(double.Parse(a[i]));

        }

        for (var i = 0; i < m; i++)
        {
            var max = list.buffer[0];
            list.Pop();
            var value = Math.Floor(max / 2);
            list.Push(value);
        }

        long ret = 0;
        foreach (var v in list.buffer)
        {
            ret += (long)v;
        }

        Console.Write(ret);
    }
}

class PriorityQueue<T> where T : IComparable<T>
{
    public List<T> buffer = new List<T>();

    public void Push(T e)
    {
        PushHeap(this.buffer, e);
    }

    public void Pop()
    {
        PopHeap(this.buffer);
    }

    public void PushHeap(List<T> array, T e)
    {
        var n = array.Count;
        array.Add(e);

        while (n != 0)
        {
            int i = (n - 1) / 2;
            if (array[n].CompareTo(array[i]) > 0)
            {
                T tmp = array[n];
                array[n] = array[i];
                array[i] = tmp;
            }
            n = i;
        }
    }

    public void PopHeap(List<T> array)
    {
        var n = array.Count - 1;
        array[0] = array[n];
        array.RemoveAt(n);

        for (int i = 0, j; (j = 2 * i + 1) < n;)
        {
            if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) < 0)) j++;
            if (array[i].CompareTo(array[j]) < 0)
            {
                T tmp = array[j];
                array[j] = array[i];
                array[i] = tmp;
            }
            i = j;
        }
    }

}




Measured memory_bytes: 26588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i,n) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(all(a),greater<P>());
  ll ans = 0;
  vector<vector<ll> > dp(n+5, vector<ll>(n+5, 0));
  for (int l = 0; l <= n; ++l) {
    for (int r = 0; r <= n; ++r) {
      if (l + r == n) {
        chmax(ans, dp[l][r]);
        break;
      }
      int idx = a[r+l].second;
      ll act = a[r+l].first;
      chmax(dp[l+1][r], dp[l][r] + act * (ll)fabs(l - idx)); //左におく
      chmax(dp[l][r+1], dp[l][r] + act * (ll)fabs((n-1-r) - idx)); //右におく
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 34560
import java.util.Scanner;

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

        System.out.println(lcm(A, B));

        sc.close();
    }

    public static long lcm(long a, long b) {
        long c = a * b;
        long maxVal = Math.max(a, b);
        long minVal = Math.min(a, b);

        long tmp = 0;
        while ((tmp = maxVal % minVal) != 0) {
            maxVal = minVal;
            minVal = tmp;
        }

        return (c / minVal);
    }
}


Measured memory_bytes: 35812
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int N;
	cin >> N;
	vector<int> A(N+2);
	for(int i = 1; i <= N; ++i) {
		cin >> A[i];
	}
	int sum = 0;
	for(int i = 0; i <= N; ++i) {
		sum += abs(A[i+1] - A[i]);
	}
	for(int i = 1; i <= N; ++i) {
		cout << sum - (abs(A[i] - A[i-1]) + abs(A[i+1] - A[i])) + (abs(A[i+1] - A[i-1])) << endl;
	}
	return 0;
}


Measured memory_bytes: 2048
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)



        
def main(): #startline--------------------------------------------
    n = int(input())
    h = list(map(int,input().split()))
    dp = [0]*(n)
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(1,n-1):
        dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))
    print(dp[n-1])
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 16344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll p=1000000007;
ll factfastaf(ll n)
{
     if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p ; 
  
    return result; 
 }
  

int main()
{
	ll n;
   cin>>n;
  ll r= factfastaf(n);
  cout<<(r);
  return 0;
}
    

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

int main() {
  string s; cin >> s;
  ll ans;
  if(s[0]=='2') ans++;
  if(s[1]=='2') ans++;
  if(s[2]=='2') ans++;
  if(s[3]=='2') ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       ll n,i;
       cin>>n;
       ll ans=1,ans2=1,ans3=1;
       for(i=0;i<n;i++)
        ans*=10,ans%=Mod,ans+=Mod,ans%=Mod;
       for(i=0;i<n;i++)
        ans2*=8,ans2%=Mod,ans2+=Mod,ans2%=Mod;
       for(i=0;i<n;i++)
        ans3*=9,ans3%=Mod,ans3+=Mod,ans3%=Mod; 
       ans-=2*ans3-ans2;
       ans%=Mod;
       ans+=Mod;
       ans%=Mod;
       cout<<ans;  
   }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> l, r;
    rep(i, m){ 
        int tmpl, tmpr; 
        cin >> tmpl >> tmpr;
        l.push_back(tmpl);
        r.push_back(tmpr);
    }
    sort(l.begin(), l.end(), greater<int>());
    sort(r.begin(), r.end());

    int ans = 0;
    if(l[0] <= r[0]){
        ans = r[0] -l[0]+1;
    } 

    cout << ans << endl;
}




Measured memory_bytes: 1276
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{self, prelude::*};

#[allow(unused_must_use)]
#[allow(unused_assignments)]
#[allow(unused_variables)]
fn solve<B: BufRead, W: Write>(mut scan: Scanner<B>, mut w: W) {
    let n: usize = scan.token();
    let n: String = n.to_string();
    let n: Vec<char> = n.chars().collect();

    let mut ans = "No";

    for c in n.iter() {
        if *c == '7' {
            ans = "Yes";
        }
    }

    writeln!(w, "{}", ans);
}
 
fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    solve(reader, writer);
}
#[allow(dead_code)]
fn vector_to_str<T: ToString>(vector: &Vec<T>, separator: &str) -> String { 
    use std::fmt::Write;
    let mut ans = String::new();
    for line in vector.iter() {
        write!(&mut ans, "{}{}", line.to_string(), separator).unwrap();
    }
    ans
}
#[allow(dead_code)]
fn matrix_to_str<T: ToString>(matrix: &Vec<Vec<T>>, separator: &str) -> String { 
    use std::fmt::Write;
    let mut ans = String::new();
    for line in matrix.iter() {
        for elem in line.iter() {
            write!(&mut ans, "{}{}", elem.to_string(), separator).unwrap();
        }
        write!(&mut ans, "\n").unwrap();
    }
    ans
}
pub struct Scanner<B> {
    reader: B,
    buf_str: Vec<u8>,
    buf_iter: std::str::SplitWhitespace<'static>,
}
impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buf_str: Vec::new(),
            buf_iter: "".split_whitespace()
        }
    }
    pub fn token<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
            self.buf_iter = unsafe {
                let slice = std::str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace()) }
        }
    }
    pub fn get_matrix<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>> {
        // m rows and n columns
        let mut ans: Vec<Vec<T>> = Vec::with_capacity(m);
        for i in 0..m {
            ans.push(Vec::with_capacity(n));
            for _ in 0..n {
                ans[i].push(self.token::<T>());
            }
        }
        ans
    }
    pub fn get_vector<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut ans: Vec<T> = Vec::with_capacity(n);
        for _ in 0..n {
            ans.push(self.token::<T>());
        }
        ans
    }
}


Measured memory_bytes: 2160
import sys
from itertools import accumulate
readline = sys.stdin.readline
MOD = 10**9+7

N, C = map(int, readline().split())
A = [0] + list(map(int, readline().split()))
B = [0] + list(map(int, readline().split()))

acsq = []
lb = max(B)+1
for j in range(C+1):
    ac = [0]*lb
    ac[0] = 1
    for i in range(1, lb):
        ac[i] = (ac[i-1] + pow(i, j, MOD)) % MOD
    acsq.append(ac)
dp = [[0]*(C+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    a, b = A[i], B[i]
    for c in range(C+1):
        res = 0
        for j in range(c+1):
            res = (res + (acsq[c-j][b] - acsq[c-j][a-1])*dp[i-1][j]) % MOD
        dp[i][c] = res
print(dp[N][C])

Measured memory_bytes: 44524
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int A[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    int B[m];
    for(int i=0;i<m;i++){
        cin>>B[i];
    }
    int C[n]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            C[i]+=A[i][j]*B[j];
        }
        cout<<C[i]<<endl;
    }
    
}


Measured memory_bytes: 3100
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

class TEdge;
struct TNode
{
	int TreeIndex;
	std::set<const TEdge*> Connected;
	
	TNode();
	void SetIndex(int Index, const TEdge* Edge);
};

class TEdge
{
	std::pair<TNode*, TNode*> FEnds;
	int FWeight;
public:
	TEdge(TNode* EndA, TNode* EndB, int Weight);
	
	bool operator<(const TEdge& Other)const;
	int  Weight()const {return FWeight;}
	bool ToMekeCycle()const;
	
	void JoinTree(int TreeIndex)const;
};

TNode::TNode()
:TreeIndex(0)
{
}

void TNode::SetIndex(int Index, const TEdge* Edge)
{
	if(TreeIndex >= Index) return;
	TreeIndex = Index;
	for(std::set<const TEdge*>::const_iterator It = Connected.begin(); It != Connected.end(); ++It){
		(*It)->JoinTree(Index);
	}
	Connected.insert(Edge);
}

TEdge::TEdge(TNode* EndA, TNode* EndB, int Weight)
:FEnds(EndA, EndB), FWeight(Weight)
{
}

bool TEdge::operator<(const TEdge& Other)const
{
	return Weight() < Other.Weight();
}

bool TEdge::ToMekeCycle()const
{
	return FEnds.first->TreeIndex > 0 && FEnds.first->TreeIndex == FEnds.second->TreeIndex;
}

void TEdge::JoinTree(int TreeIndex)const
{
	FEnds.first->SetIndex(TreeIndex, this);
	FEnds.second->SetIndex(TreeIndex, this);
}

class TGraph
{
	std::vector<TNode> FNodes;
	std::vector<TEdge> FEdges;
public:
	TGraph(int NodeCount);
	
	void AddEdge(int NodeIndexA, int NodeIndexB, int Weight);
	int WeightMinimumSpanningTree();
};

TGraph::TGraph(int NodeCount)
:FNodes(NodeCount)
{
}

void TGraph::AddEdge(int NodeIndexA, int NodeIndexB, int Weight)
{
	if(NodeIndexA <= NodeIndexB || Weight < 0) return;
	FEdges.push_back(TEdge(&FNodes[NodeIndexA], &FNodes[NodeIndexB], Weight));
}

int TGraph::WeightMinimumSpanningTree()
{
	std::sort(FEdges.begin(), FEdges.end());
	unsigned int TreeCount = 0;
	int Weight = 0;
	for(std::vector<TEdge>::iterator It = FEdges.begin(); It != FEdges.end() && TreeCount < FNodes.size() - 1; ++It){
		if(It->ToMekeCycle()) continue;
		It->JoinTree(TreeCount + 1);
		Weight += It->Weight();
		++TreeCount;
	}
	return Weight;
}

int main()
{
	int NodeCount;
	std::cin >> NodeCount;
	TGraph Graph(NodeCount);
	
	for(int i = 0; i < NodeCount; ++i)
	{
		for(int j = 0; j < NodeCount; ++j){
			int Weight;
			std::cin >> Weight;
			Graph.AddEdge(i, j, Weight);
		}
	}
	
	std::cout << Graph.WeightMinimumSpanningTree() << std::endl;
	return 0;
}

Measured memory_bytes: 3240
v, e = gets.split.map(&:to_i)
vst = [false]*v
g = v.times.map{[]}
rg = v.times.map{[]}
e.times do
  s,t = gets.split.map(&:to_i)
  g[s] << t
  rg[t] << s
end
arr = rg.map.with_index{|a, i| i if a.empty? }.compact
cnt = 0
while vst.any?{ |e| !e }
  i = arr.shift
  vst[i] = cnt
  g[i].each{|t| rg[t].delete(i); arr << t if rg[t].empty?}
  cnt += 1
end
vst.map.with_index{|e, i| [e, i]}.sort.each{|a| p a[1]}

Measured memory_bytes: 12716
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),count=0;
    int[] a=new int[n];
    for(int i=0;i<n;i++)a[i]=sc.nextInt();
    for(int i=0;i<n-1;i++) {
    	if(a[i]==a[i+1]) {
    		a[i+1]=-1;
    		count++;
    	}
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 23892
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

const int MAX_N = 1e2 + 10 ;

int len1 , len2 ;
char s1[MAX_N] , s2[MAX_N] ;

bool cmp1(char a , char b) {return a < b ;}
bool cmp2(char a , char b) {return a > b ;}

int main() {
	scanf("%s %s" , s1 , s2) ;
	len1 = strlen(s1) ; len2 = strlen(s2) ;

	//

	std::sort(s1 + 0 , s1 + len1 , cmp1) ;
	std::sort(s2 + 0 , s2 + len2 , cmp2) ;

	int p = 0 , L = std::min(len1 , len2) ;
	for (; p < L && s1[p] == s2[p] ; ++p) ;

	if (p == L) {
		if (len1 >= len2) printf("No\n") ;
		else printf("Yes\n") ;
	}
	else {
		if (s1[p] > s2[p]) printf("No\n") ;
		else printf("Yes\n") ;
	}

	return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int t[200010];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=1; i<=n; i++)
        scanf("%d",&t[i]);
    for(int i=1; i<=n-m; i++)
        if(t[i+m]>t[i])
            printf("Yes\n");
        else
            printf("No\n");
    return 0;
}


Measured memory_bytes: 4460
//@source : 
//@create : 19:09:29 Saturday 27/06/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    cout << n + n * n + n * n * n << "\n";
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    while (t--) {
        solve();
    }
    //cerr << fixed << setprecision(5) << double(clock()) * 1000 / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	mx := 0
	A[0]--
	for i := 1; i < N; i++ {
		if A[i-1] < A[i] {
			A[i]--
		}
	}

	for i := 0; i < N; i++ {
		if mx <= A[i] {
			mx = A[i]
		} else {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n,i,t;
    cin>>n;
    multiset<int>a,b;

    for(i=0;i<n-1;i++){
            cin>>t;
            a.insert(t);
    }
    for(int i=1;i<=n;i++){
       cout<<a.count(i)<<endl;
    }
}


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

bool graph[8][8];

int dfs(int v, int N, bool visited[8]) {
  
  // 全ての点にいけるか否かの確認
  bool all = true;

  for (int i = 0; i < N; i++) {
    if (visited[i] == false) {
      all = false;
    }
  }

  // 全ての点にいける場合は、回答に1（パターン）を追加する
  if (all){
    return 1;
  }

  int result = 0;

  for (int i = 0; i < N; i++) {
    if (graph[v][i] == false) {
      continue;
    }
    if (visited[i]) {
      continue;
    }
    
    // 点iを訪問済みとした場合
    visited[i] = true;
    
    // 点iから次のdfs 
    result += dfs(i, N, visited);

    // 点iを未訪問にした場合
    visited[i] = false;

  }

  return result;

}


int main() {

  int N, M;
  cin >> N >> M;
  
  for (int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    graph[a - 1][b - 1] = true;
    graph[b - 1][a - 1] = true;
  }

  bool visited[8];
  for (int i = 0; i < N; i++) {
    visited[i] = false;
  }

  // 1からスタートする
  visited[0] = true;

  int answer = dfs(0, N, visited);

  cout << answer <<  endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int N, M;
  string s;
  read N >> M;
  vector<string> data(N);

  REP(i, N) {
    read s;
    data[i] = s;
  }
  // 横チェック
  REP(i, N) {
    bool erace_flag = true;
    REP(j, M) {
      if (data[i][j] == '#') {
        erace_flag = false;
      }
    }
    if (erace_flag) {
      REP(j, M) { data[i][j] = '-'; }
    }
  }

  // 縦チェック
  REP(j, M) {
    bool erace_flag = true;
    REP(i, N) {
      if (data[i][j] == '#') {
        erace_flag = false;
      }
    }
    if (erace_flag) {
      REP(i, N) { data[i][j] = '-'; }
    }
  }
  REP(i, N) {
    bool endl_flag = false;
    REP(j, M) {
      if (data[i][j] != '-') {
        endl_flag = true;
        if (j == M - 1) {
          cout << data[i][j] << endl;
        } else {
          cout << data[i][j];
        }
      } else if (j == M - 1 && endl_flag) {
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
 
class Main{

static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
 
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
char[] pic=br.readLine().toCharArray();
int[][] dp=new int[n][8];
if(pic[0]=='J'){
dp[0][1]=1;
dp[0][4]=1;
dp[0][6]=1;
dp[0][7]=1;
}
if(pic[0]=='O'){
dp[0][4]=1;
dp[0][7]=1;
}
if(pic[0]=='I'){
dp[0][6]=1;
dp[0][7]=1;
}
for(int i=1;i<n;i++){
if(pic[i]=='J'){
dp[i][1]=(dp[i-1][1]+dp[i-1][4]+dp[i-1][6]+dp[i-1][7])%MOD;
dp[i][4]=(dp[i-1][1]+dp[i-1][2]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]+dp[i-1][7])%MOD;
dp[i][6]=(dp[i-1][1]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]+dp[i-1][7])%MOD;
dp[i][7]=(dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]+dp[i-1][7])%MOD;
}
if(pic[i]=='O'){
dp[i][2]=(dp[i-1][2]+dp[i-1][4]+dp[i-1][5]+dp[i-1][7])%MOD;
dp[i][4]=(dp[i-1][2]+dp[i-1][1]+dp[i-1][4]+dp[i-1][6]+dp[i-1][5]+dp[i-1][7])%MOD;
dp[i][5]=(dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][6]+dp[i-1][5]+dp[i-1][7])%MOD;
dp[i][7]=(dp[i-1][2]+dp[i-1][1]+dp[i-1][3]+dp[i-1][4]+dp[i-1][6]+dp[i-1][5]+dp[i-1][7])%MOD;
}
if(pic[i]=='I'){
dp[i][3]=(dp[i-1][3]+dp[i-1][5]+dp[i-1][6]+dp[i-1][7])%MOD;
dp[i][5]=(dp[i-1][3]+dp[i-1][2]+dp[i-1][5]+dp[i-1][4]+dp[i-1][6]+dp[i-1][7])%MOD;
dp[i][6]=(dp[i-1][3]+dp[i-1][1]+dp[i-1][5]+dp[i-1][4]+dp[i-1][6]+dp[i-1][7])%MOD;
dp[i][7]=(dp[i-1][3]+dp[i-1][2]+dp[i-1][1]+dp[i-1][5]+dp[i-1][4]+dp[i-1][6]+dp[i-1][7])%MOD;
}
}
int ans=0;
for(int i=1;i<=7;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
}

Measured memory_bytes: 17084
timeNum = int(input())

placeSequence = list()
for pivot in range(timeNum):
  placeSequence.append(list(map(int, input().split(' '))))

def compatibleCoordinate(time, x, y):
  if time % 2 == (abs(x) +  abs(y)) % 2 and time >= abs(x) + abs(y):
    return True
  else:
    return False

time = x = y = 0

for place in placeSequence:
  objectTime, objectX, objectY = place
  flag = compatibleCoordinate(objectTime-time, objectX-x, objectY-y)
  if flag:
    time = objectTime
    x = objectX
    y = objectY
    continue
  else:
    print('No')
    break

else:
  print('Yes')

Measured memory_bytes: 27324
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

int k, a, b, flag;

int main() {
   cin >> k >> a >> b;
   for(int i = a; i <= b; ++i) {
      if(!(i%k)) flag = 1;
   }
   flag ? puts("OK") : puts("NG");
}

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

int main(){
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  
  for(int i =0; i<3;i++){
  if(A[i] == 5){A[i] = 0;
               break;}
    }
  for(int i =0; i<3;i++){
  if(A[i] == 5){A[i] = 0;
               break;}
    }
  for(int i =0; i<3;i++){
  if(A[i] == 7){A[i] = 0;
               break;}
    }
  if(A[0] == 0 && A[1] == 0 && A[2] == 0){
  cout << "YES" << endl;}else{cout << "NO" << endl;}
}

Measured memory_bytes: 256