akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define SQR(a) ((a)*(a))
using namespace std;
typedef long long int ll;
typedef pair<int,int> pr;
typedef pair<pr,ll> ppr;
typedef vector<pr> vpr;
const int INF=1<<30;
vpr edge[101];
int dijkstra(int a,int b){
	priority_queue<pr,vpr,greater<pr> > pq;
	int dist[101]={};
	REP(j,101)
	dist[j]=INF;
	dist[a]=0;
	pq.push(pr(dist[a],a));
	while(!pq.empty()){
		int cost=pq.top().first,p=pq.top().second;
		pq.pop();
		if(dist[p]!=cost)
		continue;
		REP(i,edge[p].size()){
			int next=edge[p][i].second,edgeDist=edge[p][i].first;
			if(dist[next]>edgeDist+cost){
				dist[next]=edgeDist+cost;
				pq.push(pr(dist[next],next));
			}
		}
	}
	if(dist[b]==INF)
	return -1;
	else
	return dist[b];
}
int main() {
	int n,k,type,a,b,e;
	while(cin >> n >> k && n){
	REP(i,101)
	edge[i].clear();
	REP(i,k){
		cin >> type >> a >> b;
		if(!type)
			cout << dijkstra(a,b) << endl;
		else{
			cin >> e;
			edge[a].push_back(pr(e,b));
			edge[b].push_back(pr(e,a));
		}
	}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

typedef long double ld;

const ld pi = acos(-1);

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

	cout << fixed << setprecision(16);

	ld a, b, x;
	cin >> a >> b >> x;
	ld s = (x / (a));
	ld rs = a * b - s;
	if (s >= rs) {
		ld z = 2 * rs / a;
		ld ans = atan2(z, a);
		cout << (ans / (2 * pi)) * 360 << endl;
	} else {
		ld z = 2 * s / b;
		ld ans = atan2(z, b);
		cout << (ld)90 - (ans / (2 * pi)) * (ld)360 << endl;
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;
    vector<pair<ll,ll>> ans;
    ll M = 0;
    if(N % 2 == 1){
        FOR(i,1,N+1){
            FOR(j,i+1,N+1){
                if(i + j != N){
                    ans.emplace_back(i,j);
                    M++;
                }
            }
        }
    }else{
        FOR(i,1,N+1){
            FOR(j,i+1,N+1){
                if(i + j != N + 1){
                    ans.emplace_back(i,j);
                    M++;
                }
            }
        }
    }
    cout << M << endl;
    rep(i,M) cout << ans[i].first << ' ' << ans[i].second << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll MAX_N = 1e5 + 1;

ll a[MAX_N];
ll b[MAX_N];
int par[MAX_N];
int rak[MAX_N];
int s[MAX_N];

void init(int n) {
	repe(i, 0, n) {
		par[i] = i;
		rak[i] = 0;
		s[i] = 1;
	}
}

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

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rak[x] < rak[y]) par[x] = y;
	else {
		par[x] = y;
		if (rak[x] == rak[y]) rak[x]++;
	}
}

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

/////////////////////////////////////////////

int main() {
	ll n, m; cin >> n >> m;
	init(n);
	rep(i, 0, m)cin >> a[i] >> b[i];
	ll ans = n * (n - 1) / 2;
	vector<ll> v;
	v.push_back(ans);

	for (int i = m - 1; i >= 1; i--) {
		if (!same(a[i], b[i])) {
			ll x = s[find(a[i])];
			ll y = s[find(b[i])];

			s[find(b[i])] += s[find(a[i])];
			unite(a[i], b[i]);
			ans -= x * y;
		}
		v.push_back(ans);
	}

	reverse(v.begin(), v.end());
	for (vector<ll>::iterator it = v.begin(); it != v.end(); it++) 	cout << *it << endl;
	return 0;
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  short int N,j,i;
  cin >> N;
  vector<int> a(N);
  short int score=0;
  for(i=0;i<N;++i)
    cin >> a.at(i);
  for(bool is_solved=false;is_solved==false;){
    j=0;
    for(i=0;i<(N-1);++i)
      if(a.at(i)<a.at(i+1)){
        ++j;
        a.at(i) ^= a.at(i+1);
        a.at(i+1) ^= a.at(i);
        a.at(i) ^= a.at(i+1);
      }
    if(j==0)
      is_solved = true;
  }
  for(i=0;i<N;++i)
    score += a.at(i) * (1-(i%2==1)*2);
  cout << score << endl;
  
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int ans = 0;
    for(int i = 0; i < n - 2; ++i) {
        if(p[i+1]>p[i] && p[i+1] < p[i+2]) {
            ans++;
        }else if (p[i+1]<p[i] && p[i+1] > p[i+2]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int count = 0;

void merge(int A[], int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;

  int L[n1 + 1];
  for (int i = 0; i < n1; ++i)
  {
    L[i] = A[left + i];
  }
  L[n1] = 1000000000 + 1;

  int R[n2 + 1];
  for (int i = 0; i < n2; ++i)
  {
    R[i] = A[mid + i];
  }
  R[n2] = 1000000000 + 1;

  int i = 0;
  int j = 0;
  for (int k = left; k < right; ++k)
  {
    ++count;
    if (L[i] <= R[j])
    {
      A[k] = L[i];
      ++i;
    }
    else
    {
      A[k] = R[j];
      ++j;
    }
  }
}

void merge_sort(int A[], int left, int right)
{
  if (left + 1 < right)
  {
    int mid = (left + right) / 2;
    merge_sort(A, left, mid);
    merge_sort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

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

  merge_sort(S, 0, n);

  for (int i = 0; i < n; ++i)
  {
    if (i != 0) cout << ' ';
    cout << S[i];
  }
  cout << endl;
  cout << count << endl;

  return 0;
}



Measured memory_bytes: 6888
import sys
input=sys.stdin.readline

def main():
    m=int(input())
    DC=[list(map(int,input().split())) for _ in range(m)]
    s=0
    digit=0
    for d,c in DC:
        digit+=c
        s+=d*c
    print(digit-1+(s-1)//9)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 73692
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    string s, t;
    cin >> s >> t;
    ll ans = INT_MAX;
    for(ll i = 0; i <= s.size() - t.size(); i++){
        string sb = s.substr(i, t.size());
        // cout << sb << " ";
        ll count = 0;
        for(ll j = 0; j < sb.size(); j++){
            if(sb[j] != t[j]){
                count++;
            }
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
/*
 Author: Alokit Kumar
 */
 #include<bits/stdc++.h>
 using namespace std;
 #define int long long
 int32_t main()
 {
   int t,n,i,j,k,l=0,m,min1=0;
   cin>>n>>m>>k;
   int a[n+1],b[m+1];
   for(i=1;i<=n;i++) cin>>a[i];
   for(i=1;i<=m;i++) cin>>b[i];
   int dp[n+1],dp1[m+1];dp[0]=0;
   dp[1]=a[1];
   for(i=2;i<=n;i++)
    dp[i]=dp[i-1]+a[i];
    dp1[0]=0;
    map<int,int> m1;
    for(i=1;i<=m;i++) dp1[i]=dp1[i-1]+b[i];
    for(i=1;i<=m;i++)
     m1[dp1[i]]=i;
    for(i=0;i<=n;i++)
    {
      j=dp[i];
      if(j>k)
       break;
      l=k-j;
      auto it=m1.upper_bound(l);
      if(it==m1.begin())
       j=0;
      else
      {
        it--;
        j=(it->second);
      }
      min1=max(min1,i+j);
    }
    cout<<min1;
 }


Measured memory_bytes: 22320
program tiles
	implicit none
	character(len=10**5) :: s, p, q
	integer :: x, i, c1, c2
    
	c1 = 0
    c2 = 0
    
	read(*,*) s    
	x = len_trim(s)
    
    i = 1
	do i = 1, x, 2
		p(i:i) = '0'
        q(i:i) = '1'
    end do
    i = 1
    do i = 2, x, 2
    	p(i:i) = '1'
        q(i:i) = '0'
    end do 
	i = 1    
    do i = 1, x
    	if (p(i:i) /= s(i:i)) then
        	c1 = c1 + 1
        end if
        if (q(i:i) /= s(i:i)) then
        	c2 = c2 + 1
        end if
    end do
    write(*,*) min(c1,c2)
    stop
end program tiles

Measured memory_bytes: 3344
n,c=map(int,input().split())
t=[[0 for i in range(100001)] for j in range(c)]

for i in range(n):
    si,ti,ci = map(int,input().split())
    for j in range(si,ti+1):
        t[ci-1][j] = 1
print(max(sum(t[j][i] for j in range(c)) for i in range(100001)))

Measured memory_bytes: 26672
#include <stdio.h>

int main(){
    int x,y,z;
    double output;
    int answer;
    scanf("%d %d %d", &x, &y, &z);
    if(x % y == 0) {
        output = x/y;
    }
    else {
        output = x/y + 1;
    } 
    //printf("output:%1.1f\n", output);
    answer=output*z;
    printf("%d\n", answer);

    return 0;
}


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

using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}
//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int gcd(int a,int b){//最大公約数
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}


int experiment(){
    int ans;ans=0;
    int N;
    cin>>N;
    vector<string> s,s2;
    FOR(i, 0, N){
        string st;
        cin>>st;
        s.push_back(st);
    }
    //pf("s size is %d\n",(int)s.size());
    s2=s;
    sort(s2.begin(),s2.end());
    s2.erase( unique(s2.begin(),s2.end()), s2.end());
    //pf("s2 size is %d\n",(int)s2.size());
    if(s2.size()!=N)OutputAndReturn0("No");
    
    FOR(i, 0, N-1){
        if(s[i][s[i].size()-1]!=s[i+1][0])OutputAndReturn0("No");
    }
    
    OutputAndReturn0("Yes");
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::max;
using std::size_t;
using std::vector;

int calc_satisfaction(const vector<int> &last, const vector<int> &c,
                      const int d, const size_t held) {
    int satisfaction = 0;
    for (size_t i = 0uL; i < 26uL; ++i) {
        if (i == held) continue;
        satisfaction += c.at(i) * (d - last.at(i));
    }
    return satisfaction;
}

int main() {
    // input
    int D;  // 365
    cin >> D;
    vector<int> c(26);  // 満足度の減衰 / day
    for (int &ci : c) cin >> ci;
    vector<vector<int>> s(D, c);  // 満足度の上昇
    for (auto &si : s) {
        for (int &sij : si) cin >> sij;
    }

    // solve
    vector<int> last(26, 0);
    vector<int> t(D, -1);
    // とりあえず各日で最大になるように貪欲
    for (int d = 0; d < D; ++d) {
        int max_satisfaction = -1000000009;
        for (int i = 0; i < 26; ++i) {
            int satisfaction = calc_satisfaction(last, c, d + 1, i);
            if (max_satisfaction < max(s.at(d).at(i), satisfaction)) {
                max_satisfaction = max(s.at(d).at(i), satisfaction);
                t.at(d)          = i + 1;
                continue;
            }
            if (max_satisfaction == max(s.at(d).at(i), satisfaction)) {
                if (c.at(i) > c.at(t.at(d) - 1)) {
                    t.at(d) = i + 1;
                }
            }
        }
    }

    // output
    for (const int ti : t) cout << ti << '\n';

    return 0;
}

Measured memory_bytes: 3692
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
using mat = vector<vector<ll>>;
using vec = vector<ll>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){

int N;
cin>>N;
rep3(i,9)rep3(j,9){
    if(i*j==N){
        cout<<"Yes"<<endl;
        return 0;
    }
}
cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 3596
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int a = cin.nextInt();
    int b = cin.nextInt();

    int res = 0;
    if (a>=b) {
      res+=a;
      a--;
    }
    else {
      res+=b;
      b--;
    }

    if (a>=b) {
      res+=a;
      a--;
    }
    else {
      res+=b;
      b--;
    }
    System.out.println(res);
  }

}


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

int main(){
    int N;
    int a[110];
    cin >> N;
    for(int i=0; i<N; ++i) cin >> a[i];
    
    sort(a, a+N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for(int i=0; i<N; i++){
        if(i%2==0){
             Alice += a[i];
        }
        else{
            Bob += a[i];
        }
    }
    
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
import math
n = int(input())
divset = []


m = math.ceil(math.sqrt(n))
for i in range(m, 0, -1):
    if n % i == 0:
        j = n / i
        print(max(math.floor(math.log10(i)), math.floor(math.log10(j)))+1)
        exit()


Measured memory_bytes: 3188
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]
from itertools import permutations
def distance(s):
    res = 0
    for i in range(n-1):
        res += ((s[i][0]-s[i+1][0])**2 + (s[i][1]-s[i+1][1])**2)**0.5
    return res
k = 0
for key in list(permutations(s,n)):
    k += distance(key)
fin_res = format(k/len(list(permutations(s,n))),'.10f')
print(fin_res)

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  int g = -1, m = 0;
  for (int a, i = 0; i < n; ++i) {
    scanf("%d", &a);
    m = max(m, a);
    if (g == -1) g = a;
    else g = __gcd(g, a);
  }
  if (k > m || k % g) puts("IMPOSSIBLE");
  else puts("POSSIBLE");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>

using namespace std;
int a[200010],cnt[4000010] = {},num[200010] = {};
int main(){
    int i,j,n,m;
    cin >> n >> m;
    for(i=0;i<n;i++){
        cin >> a[i];
        num[a[i]]++;
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=num[i];j++){
            cnt[i - j + 200000]++;
        }
    }
    int ans = 0;
    for(i=0;i<=400000;i++){
        if(i<200000) ans += cnt[i];
        else ans += max(cnt[i] - 1,0); 
    }
    for(i=0;i<m;i++){
        int x,y; cin >> x >> y; x--;
        int z = a[x];
        cnt[z - num[z] + 200000]--;
        if(z - num[z]>=0 && cnt[z - num[z] + 200000]>=1) ans--;
        if(z - num[z]<0 && cnt[z - num[z] + 200000]>=0) ans--;
        num[z]--;
        cnt[y - (num[y] + 1) + 200000]++;
        if(y - (num[y] + 1)>=0 && cnt[y - (num[y] + 1) + 200000]>1) ans++;
        if(y - (num[y] + 1)<0 && cnt[y - (num[y] + 1) + 200000]>0) ans++;
        num[y]++;
        a[x] = y;
        cout << ans << endl;
    }
}

Measured memory_bytes: 5632
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int N,V[23],C[23];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &V[i]);
	rep(i, N) scanf("%d", &C[i]);

	int ans = 0;
	rep(i, N) if (V[i] - C[i] > 0) ans += V[i] - C[i];


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

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define see(x) cerr<<#x<<"="<<x<<endl;
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll fast(ll x,ll n) {ll ans=1;for(;n;n>>=1,x=x*x%mod) if(n&1) ans=ans*x%mod; return ans;}
const int N=1e6+100;

int main() {
    ll n;
    ll ans=0;
    cin>>n;
    for(int a=1;a<=n;a++)
        for(int b=1;b<=n;b++)
    for(int c=1;c<=n;c++) {
        int x=__gcd(a,b);
        ans+=__gcd(x,c);
    }
    cout<<ans;
}


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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans=0;
    for(int rr = 0; rr <= n; rr+=r)
    {
        for(int gg = 0; gg + rr <= n; gg+=g)
        {
            int bb=n-rr-gg;
            if(bb%b!=0) continue;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		Scanner sc = new Scanner(System.in);
//		Integer h = sc.nextInt();
//		Integer w = sc.nextInt();
//		Integer n = sc.nextInt();
		String[] tmp = in.readLine().split(" ");
		Integer h = Integer.parseInt(tmp[0]);
		Integer w = Integer.parseInt(tmp[1]);
		Integer n = Integer.parseInt(tmp[2]);
		Integer a, b;
		Map<String, Integer> candidates = new HashMap<>();
		long[] result = new long[10];
		
		for (int i = 0; i < n; i++) {
			tmp = in.readLine().split(" ");
			a = Integer.parseInt(tmp[0]);
			b = Integer.parseInt(tmp[1]);
			for (int x = 2; x >= 0; x--) {
				for (int y = 2; y >= 0; y--) {
					if (a - x >= 1 && b - y >= 1 && (a - x + 2) <= h && (b - y + 2) <= w) {
						String key = (a - x) + "+" + (b - y);
						if (candidates.containsKey(key)) {
							candidates.put(key, candidates.get(key) + 1);
						} else {
							candidates.put(key, 1);
						}
					}
				}
			}
		}
		
		result[0] = (long) (h - 2) * (w - 2) - candidates.size();
		for (Map.Entry<String, Integer> candidate : candidates.entrySet()) {
			result[candidate.getValue()]++;
		}
		
		for (int j = 0; j <= 9; j++) {
			System.out.println(result[j]);
		}
	}
}

Measured memory_bytes: 177040
import sys
sys.setrecursionlimit(10000)
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1) # 有向グラフ

# メモ化再帰
dp = [-1 for _ in range(100100)]
def rec(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for i in graph[v]:
        res = max(res, rec(i) + 1)
    dp[v] = res
    return res

res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(a+b,min(a+c,b+c))<< endl;
    return 0;
}


Measured memory_bytes: 256
homework = list(map(int, input().split(' ')))
days = list(map(int, input().split(' ')))
day_sum = 0

for i in range(len(days)):
    day_sum += days[i]

if homework[0] - day_sum < 0:
    print(-1)
else:
    print(homework[0] - day_sum)


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

int main(){
    int d,g;
    cin>>d>>g;
    int p[d],c[d];
    for(int i=0;i<d;i++){
        cin>>p[i]>>c[i];
    }

    long long point=0;
    int ans=1e9;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<d); ++bit)
    {
        point=0;
        /* bit で表される集合の処理を書く */
        int last=-1;
        int cnt=0;
        for(int j=0;j<d;j++){
            if((bit>>j&1)){
                point += p[j] * (j+1) * 100 + c[j];
                cnt+=p[j];
            }
            else last=j;
        }
        if(last!=-1 && point < g && point + p[last]*(last+1)*100>=g){
            while(point < g){
                point +=(last+1)*100;
                cnt++;
            }
            ans=min(ans,cnt);
        }
        if(point >= g) ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N;
  cin>>N;
  int ANS = INF;
  for (int i = 0; i <= N; i++)
  {
    int cc = 0;
    int t = i;
    while(t > 0) cc+=t%6,t/=6;
    t = N -i;
    while(t > 0) cc+=t%9,t/=9;
    chmin(ANS,cc);
  }
  cout<<ANS<<endl;
  

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int u, v, cost; };

signed main() {
	int r; cin >> r;
	if (r < 1200)puts("ABC");
	else if (r < 2800)puts("ARC");
	else puts("AGC");
}


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

int main()
{
	int n, x;
	cin >> n >> x;
	int ret = 1;
	int pred = 0;
	for (int i = 0; i < n; ++i) {
		int l;
		cin >> l;
		pred = pred + l;
		if (pred <= x) {
			++ret;
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.IOException;

public class Main {

	static class FastReader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public FastReader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}
	}

	public static void main(String[] args) throws IOException {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] a = new int[n + 2];
		for (int i = 1; i < n + 1; i++) {
			a[i] = sc.nextInt();
		}

		int cost = 0;
		for (int i = 0; i < n + 1; i++) {
			cost += Math.abs(a[i] - a[i + 1]);
		}
		for (int i = 1; i < n + 1; i++)
			System.out.println(
					cost - Math.abs(a[i] - a[i + 1]) - Math.abs(a[i - 1] - a[i]) + Math.abs(a[i - 1] - a[i + 1]));
	}
}


Measured memory_bytes: 44092
n, m = gets.chomp.split(' ').map(&:to_i)

arr = []
m.times do
  k, *s = gets.chomp.split(' ').map(&:to_i)
  arr << s
end

p = gets.chomp.split(' ').map(&:to_i)

pat = []
0..(2**n).times do |i|
  pat << i.to_s(2).rjust(n, '0').chars.map(&:to_i)
end


counter = 0
pat.each do |pa|
  flg = true
  arr.each_with_index do |elm, idx|
    ans = 0
    elm.each do |i|
      ans += pa[i - 1]
    end
    if ans % 2 != p[idx]
      flg = false
    end
  end
  if flg
    counter += 1
  end
end

p counter

Measured memory_bytes: 2172
object Main extends App {
  import scala.io.StdIn._

  val origin = Saturday
  val Array(ay, am, ad, by, bm, bd) = readLine.trim.split(' ').map(_.toLong)
  val from = Date(ay, am.toInt, ad.toInt)
  val to = Date(by, bm.toInt, bd.toInt)
  println(calBetween(from, to))
  def calBetween(from: Date, to: Date): Long = {
    if (from > to){
      0
    }else {
      val cen4 = (to.year - from.year - 1) / 400
      val epoch = Date(from.year + cen4 * 400, from.month, from.day)
      var count = cal4CenturyRelationalWeeksAt13 * cen4
      for (year ← epoch.year to to.year; month ← 1 to 12; d ← Some(Date(year, month, 13)) if epoch <= d && d <= to) {
        if (d.week == Friday) count += 1
      }
      count
    }
  }
  def cal4CenturyRelationalWeeksAt13: Int = {
    (for (year ← 0 until 400; month ← 1 to 12) yield {
      if (Date(year, month, 13).week == Friday) 1
      else 0
    }).sum
  }

  object Date {
    val monthFromNewYear = Array(0, 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31).also(a ⇒ a.indices.tail.foreach(i ⇒ a(i) += a(i - 1)))
  }
  object Week{
    val all = Array(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday)
  }
  sealed class Week(val toInt: Int) {
    def succ(n: Int): Week = {
      Week.all((toInt + n) % 7)
    }
  }
  case object Sunday extends Week(0)
  case object Monday extends Week(1)
  case object Tuesday extends Week(2)
  case object Wednesday extends Week(3)
  case object Thursday extends Week(4)
  case object Friday extends Week(5)
  case object Saturday extends Week(6)
  case class Date(year: Long, month: Int, day: Int) extends Ordered[Date] {
    def week: Week = Saturday.succ(RelationalYearDate((year % 400).toInt, month, day).daysFromEpoch)
    override def compare(that: Date): Int = {
      if (year != that.year) year.compare(that.year)
      else if (month != that.month) month.compare(that.month)
      else day.compare(that.day)
    }
  }

  object RelationalYearDate {
    val dayFromEpochUntilNewYear = Array.tabulate(400){year ⇒ if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) 366 else 365}.also{a ⇒
      a.indices.tail.reverse.foreach(i ⇒ a(i) = a(i - 1))
      a(0) = 0
      a.indices.tail.foreach(i ⇒ a(i) += a(i - 1))
    }
    def sumDays4Century = dayFromEpochUntilNewYear.last + 365
    val dayFromNewYearUntilMonth = Array(0, 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31).also(a ⇒ a.indices.tail.foreach(i ⇒ a(i) += a(i - 1)))
  }
  case class RelationalYearDate(year: Int, month: Int, day: Int) {
    def isLeapYear: Boolean = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)
    def daysFromEpoch: Int = if (isLeapYear && month > 2) RelationalYearDate.dayFromEpochUntilNewYear(year) + RelationalYearDate.dayFromNewYearUntilMonth(month) + day
    else RelationalYearDate.dayFromEpochUntilNewYear(year) + RelationalYearDate.dayFromNewYearUntilMonth(month) + day - 1
  }
  implicit class Scope[T](val value: T) extends AnyVal{
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](func: T ⇒ A): A = func(value)

  }
}


Measured memory_bytes: 47800
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, x[300010],y[300010], q, l, r;


int32_t main(){
INIT
int d;
cin>>n>>d;
int cnt=0;
for(int i=1; i<=n; i++){
    cin>>x[i]>>y[i];
    if( (x[i]*x[i]+y[i]*y[i])<=(d*d) ){cnt++;}
}
cout<<cnt;


return 0;
}





Measured memory_bytes: 6764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

ll a[10000005];
ll dp[10000005];

void Sieve(ll n)
{
	for(ll i=2;i<=n;i++){
		if(a[i]==1) continue;
		for(ll j=i;j<=n;j+=i){
			ll cnt=1;
			while(a[j]%i==0){
				a[j]/=i; cnt++;
			}
			dp[j]*=cnt;
		}
	}
}

bool DEBUG=0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll n; cin>>n;
	fore(i,1,n){
		a[i]=i;dp[i]=i;
	}
	Sieve(n);
	
	ll sum=0;
	fore(i,1,n) sum+=dp[i];
	cout<<sum;
	
	return 0;
}


Measured memory_bytes: 159896
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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 vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;


int main() {
   string s;
  cin>>s;
  /////
  int ans=0;
  int n=s.size();
  rep(i,n){
   if(s[i]=='1')
     ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
char s[10];
bool ok;
int main(){
	scanf("%s",s+1);
	if(s[3]==s[4]&&s[5]==s[6]) ok=1;
	if(ok) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};
function buildArray(r,t){let l=t||0;for(let t=r.length;t>0;t--){const n=r[t-1];l=Array(n).fill().map(()=>JSON.parse(JSON.stringify(l)))}return l}

function main(input) {
  var o = new I(input);

  var n = o.a();
  var x = o.a();

  var burgerLength = [];
  burgerLength[1] = 5;
  for (var i = 2; i <= 50; i ++) {
    burgerLength[i] = burgerLength[i - 1] * 2 + 3;
  }
  console.log(burger(n, x));

  function burger(n, x) {
    var y = x;
    if (y > burgerLength[n]) {
      return (burgerLength[n] + 1)/2;
    }

    if (n === 1) {
      return {
        0: 0,
        1: 0,
        2: 1,
        3: 2,
        4: 3,
        5: 3
      }[y];
    }
  
    var b = 0;
    if (y > 1) {
      b += burger(n - 1, y - 1);
    }
    
    if (y > burgerLength[n - 1] + 1) {
      b += 1;
    }

    if (y > burgerLength[n - 1] + 2) {
      b += burger(n - 1, y - burgerLength[n - 1] - 2);
    }

    return b;
  }
}




main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
S = input()

if (S == 'SUN'):
    print(7)
elif (S == 'MON'):
    print(6)
elif (S == 'TUE'):
    print(5)
elif (S == 'WED'):
    print(4)
elif (S == 'THU'):
    print(3)
elif (S == 'FRI'):
    print(2)
elif (S == 'SAT'):
    print(1)

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

int main()
{
	int x[10000];
	int i = 0;
	while (true)
	{
		cin >> x[i];
		if (x[i] == 0)
		{
			break;
		}
		cout << "Case " << i + 1 << ": " << x[i] << endl;
		i++;
	}
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#ifndef d
#define d(...)
#endif
#define st first
#define nd second
#define pb push_back
#define siz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
typedef long long LL;
typedef long double LD;
constexpr int INF=1e9+7;
constexpr LL INFL=1e18;
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag,
         tree_order_statistics_node_update>;
*/

int n, q;
string S;
vector<pair<char, char>> spells;

int sim(int x) {
	for(auto& p:spells) {
		if(S[x] == p.st)
			x += (p.nd == 'L' ? -1 : 1);
		if(x == -1 or x == n) return x;
	}
	return x;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> q >> S;
	spells.resize(q);
	for(auto& p:spells)
		cin >> p.st >> p.nd;
	
	int L = 0, R = n+1;
	while(L+1 < R) {
		auto S = (L+R) / 2 - 1;
		if(sim(S) == -1)
			L = S+1;
		else
			R = S+1;
	}
	
	int a = L;
	
	L = -2, R = n-1;
	while(L+1 < R) {
		auto S = (L+R) / 2 + 1;
		if(sim(S) == n)
			R = S-1;
		else
			L = S-1;
	}
	
	int b = R;

	d(cerr << make_pair(a, b) << endl;)
	cout << max(0, b - a + 1) << "\n";
}


Measured memory_bytes: 976
"use strict"
let input=require('fs').readFileSync('/dev/stdin','utf8');
let arr=input.split(' ');
let W=parseInt(arr[0]);
let H=parseInt(arr[1]);
let x=parseInt(arr[2]);
let y=parseInt(arr[3]);
let r=parseInt(arr[4]);
let res=true;
if(W<x+r || 0>x-r) res=false;
if(H<y+r || 0>y-r) res=false;
if(res) console.log('Yes');
else console.log('No');


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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0; i<h; ++i) cin >> s[i];

  int x[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  int y[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  for(int i=0; i<h; ++i) {
    for(int j=0; j<w; ++j) {
      if(s[i][j] == '#') continue;
      int count = 0;
      for(int k=0; k<8; ++k) {
        int ni = i + y[k];
        int nj = j + x[k];
        if(ni < 0 || ni >= h) continue;
        if(nj < 0 || nj >= w) continue;
        if(s[ni][nj] == '#') count++;
      }
      s[i][j] = char(count + '0');
    }
  }
  for(int i=0; i<h; ++i) cout << s[i] << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const ll INF = 1061109567;
const ll DOG = 1000000000000001;
const double EPS = 1e-10;
int main(){
    ll N;
    string name;
    cin>>name;
    cout<<"ABC"<<name<<endl;
    return 0;
}


Measured memory_bytes: 3552
#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_N(105);
const int MOD(1000000000 + 7);

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

int power(int a, int n)
{
	int Ret(1);
	while (n)
	{
		if (n & 1)
			Ret = Mult(Ret, a);
		a = Mult(a, a), n >>= 1;
	}
	return Ret;
}

int N, H[Max_N], V, F[Max_N][3], power2[Max_N];

int solve(int l, int r)
{
	int u = ++V, Min = H[l];
	for (int i = l;i <= r;++i)
		Min = min(Min, H[i]);
	for (int i = l;i <= r;++i)
		H[i] -= Min;
	int start, v, G[Max_N][3] = {};
	if (!H[l])
		G[l][0] = G[l][1] = 1, G[l][2] = 0, start = l + 1;
	else
		for (int x = l;x <= r;++x)
			if (!H[x])
			{
				start = x, v = solve(l, --x);
				G[x][2] = F[v][2];
				G[x][0] = G[x][1] = Add(F[v][0], F[v][1]);
				break;
			}
	for (int i = start, x;i <= r;++i)
		if (!H[i])
		{
			upd(G[i][2], Mult(G[i - 1][2], 2));
			upd(G[i][2], Add(G[i - 1][0], G[i - 1][1]));
			upd(G[i][0], G[i - 1][1]), upd(G[i][1], G[i - 1][0]);
		}
		else
		{
			for (x = i;x <= r;++x)
				if (x == r || !H[x + 1])
					break;
			v = solve(i, x);
			upd(G[x][2], Mult(G[i - 1][2], Add(F[v][2], Mult(2, Add(F[v][0], F[v][1])))));
			for (int c = 0;c <= 1;++c)
			{
				upd(G[x][2], Mult(G[i - 1][c], Add(F[v][2], Add(F[v][0], F[v][1]))));
				upd(G[x][c ^ ((x - i + 1) & 1)], Mult(G[i - 1][c], Add(F[v][0], F[v][1])));
			}
			i = x;
		}
	F[u][2] = G[r][2];
	if (Min == 1)
		F[u][0] = G[r][(r - l) & 1], F[u][1] = G[r][((r - l) & 1) ^ 1];
	else
		F[u][0] = F[u][1] = Mult(Add(G[r][0], G[r][1]), power(2, Min - 2));
	return u;
}

int main()
{
	scanf("%d", &N);
	for (int i = 1;i <= N;++i)
		scanf("%d", H + i);
	power2[0] = 1;
	for (int i = 1;i <= N;++i)
		power2[i] = Add(power2[i - 1], power2[i - 1]);
	solve(1, N);
	printf("%d", Add(Add(F[1][0], F[1][1]), F[1][2]));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
long long int mod= 1000000007,modd=998244353;
int32_t main()
{
   string s;
  cin>>s;
  lli c=0;
  if(s[0]=='R') c++;
  if(s[1]=='R') c++;
  if(s[2]=='R') c++;
  if(c!=2)
    cout<<c;
  else
  { if(s[1]=='S') c--;
    cout<<c;
  }
   return 0;
}//main

Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    cout << "ABC" << s << endl;

    return 0; 
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	re(a*b)
	return 0;}

Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  FOR(i,0,n){
    int a;
    cin >> a;
    ans += a - 1;
  }
  cout << ans << endl;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl

// const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

long long binpow (long long a, long long b)
{
    long long res = 1;
    
    while (b > 0)
    {
        if (b & 1) res *= a;
        a *= a;
        b >>= 1;
    } 

    return res;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout); 
    #endif
    
    fastio(); 

    // int t; 
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    int x;
    cin >> x;

    int lcm = (x / __gcd(x, 360)) * 360;

    cout << lcm / x << "\n";
    return;
}

Measured memory_bytes: 3608
n, k, q = map(int, input().split())

n_points = [0 for _ in range(n)]

for _ in range(q):
    a = int(input())
    n_points[a-1] += 1

for n_point in n_points:
    if n_point + k > q:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 4672
#include <bits/stdc++.h>                                          // This will work only for g++ compiler.
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)             // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)            // 1 based indexing
#define forab(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n)-1; i >= 0; --i)         // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i)           // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define __builtin_popcount(x) ones(x)
#define __builtin_popcountl(x) onesl(x)
#define __builtin_popcountll(x) onesll(x) // to be used with algorithms that processes a container Eg: find(all(c
#define all(x) (x).begin(), (x).end()     //Forward traversal
#define rall(x) (x).rbegin, (x).rend()    //reverse traversal
#define tr(c, i) for (__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define sz(a) int((a).size())
#define Fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define InputOuput                    \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll linf = 1e18L + 5;
const int inf = 1e9 + 5;
const int mod = 1e9 + 7;

int md(int x)
{
    return ((x % mod) + mod) % mod;
}
int main()
{
    //InputOuput;
    Fast;
    //setprecision(2);
    int n ; cin >> n;
    vector<double> prob(n+1);
    for1(i,n ) cin >> prob[i];
    vector<vector<double > > dp(n+1, vector<double>(n+1, (double)1));
    for1(i,n){
        forab(heads, 0, i){
            double tails =
            dp[i][heads] = ( (heads == i) ?(double) 0: (1-prob[i])*dp[i-1][heads]) + ( (heads == 0)?(double)0 : prob[i]*dp[i-1][heads-1]);
        }
    }
    double ans = (double)0;
    forab(i, (n+1)/2 , n){
        ans += dp[n][i];
    }
    cout << setprecision(10)<< ans << '\n';
    return 0;
}

Measured memory_bytes: 73648
import sys
input = sys.stdin.readline
from collections import *

A, B, C, D = map(int, list(input()[:-1]))
l = [B, C, D]

for S in range(8):
    now = A
    ans = [str(A)]
    
    for i in range(3):
        if (S>>i)&1:
            now += l[i]
            ans.append('+')
        else:
            now -= l[i]
            ans.append('-')
        
        ans.append(str(l[i]))
    
    ans.append('=7')
    
    if now==7:
        print(''.join(ans))
        exit()

Measured memory_bytes: 65144
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n;
    cin >> n;
    pair<int, bool> a[n];
    REP(i, n){
        cin >> a[i].first;
        if(a[i].first % 2 == 0) a[i].second = true;
        else a[i].second = false;
    }
    REP(i, n){
        if(a[i].second){
            if((a[i].first % 3 == 0) || (a[i].first % 5 == 0))
                a[i].second = true;
            else{
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

long long fact(long long n);

int main(void){
    long long n;
    scanf("%lld",&n);
    printf("%lld\n",fact(n));
    return 0;
}

long long fact(long long n){
    if(n==1) return 1;
    return n*fact(n-1);
}



Measured memory_bytes: 2044