akhauriyash/Code-Regression huggingface dataset:
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 1e6;
int D;
int C[30];
int S[400][30];

ll score(vector<int>& t)
{
  vector<int> last(30, 0);
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    last[t[i]] = (i+1);
    REP(j,26){
      s -= C[j] * (i+1-last[j]);
    } 
  }
  return s;
}

void init(vector<int>& t)
{
  //REP(i,D) t[i] = (i%26);
  REP(i,D){
    int mx = 0;
    int ind = 0;
    REP(j,26){
      if(mx<S[i][j]){
        mx = S[i][j];
        ind = j;
      }
    }
    t[i] = ind;
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  vector<int> T(D);
  init(T);
  //REP(i,D) T[i] = rand26(mt);
  ll max_score = max(base+score(T), 0LL);
  int ti = clock();
  while(clock() - ti < 180 * CLOCKS_PER_SEC / 100){ 
    int d = rand365(mt);
    int q = rand26(mt);
    int old = T[d];
    T[d] = q;
    ll tmp = max(base + score(T), 0LL);
    if(max_score<tmp){
      max_score = tmp;
    }else{
      T[d] = old;
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


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

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

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(std::vector<long long> M, std::vector<long long> D) {
  if( M[0] != M[1] ){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}

int main() {
  std::vector<long long> M(2);
  std::vector<long long> D(2);
  for (int i = 0; i < 2; i++) {
    scanf("%lld", &M[i]);
    scanf("%lld", &D[i]);
  }
  solve(std::move(M), std::move(D));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n,k; cin>>n>>k;
	if(n<k){
		cout<<1;
		return 0;
	}
	ll ans=0;
	while(true){
		n/=k;
		ans++;
		if(n<k) break;
	}
	++ans;
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

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

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a, b; cin >> a >> b;
	if (a < b) {
		cout << 0 << endl;
	}
	else cout << 10 << endl;
}

Measured memory_bytes: 3640
n = int(input())
s = input()

def loop():
    for i in range(1, n-1):
        if ans[i] == 'S':
            if s[i] == 'x':
                if ans[i-1] == 'S':         
                    ans[i+1] = 'W'
                else:
                    ans[i+1] = 'S'
            else:
                if ans[i-1] == 'W':
                    ans[i+1] = 'W'
                else:
                    ans[i+1] = 'S'
        else:
            if s[i] == 'o':
                if ans[i-1] == 'S':
                    ans[i+1] = 'W'
                else:
                    ans[i+1] = 'S'
            else:
                if ans[i-1] == 'W':
                    ans[i+1] = 'W'
                else:
                    ans[i+1] = 'S'

ans = ['S'] + ['Unknown'] * (n-2) + ['S']
if s[0]  == 'x':
    ans[1] = 'W'
else:
    ans[1] = 'S'
loop()
if ans[n-1] == 'S':
    if (s[n-1] == 'o' and ans[n-2] == 'S') or (s[n-1] == 'x' and ans[n-2] == 'W'):
        print(''.join(ans))
        exit()

ans = ['W'] + ['Unknown'] * (n-2) + ['S']
if s[0]  == 'x':
    ans[1] = 'S'
else:
    ans[1] = 'W'
loop()
if ans[n-1] == 'S':
    if (s[n-1] == 'x' and ans[n-2] == 'S') or (s[n-1] == 'o' and ans[n-2] == 'W'):
        print(''.join(ans))
        exit()

ans = ['W'] + ['Unknown'] * (n-2) + ['W']
if s[0]  == 'x':
    ans[1] = 'W'
else:
    ans[1] = 'S'
loop()
if ans[n-1] == 'W':
    if (s[n-1] == 'x' and ans[n-2] == 'W') or (s[n-1] == 'o' and ans[n-2] == 'S'):
        print(''.join(ans))
        exit()

ans = ['S'] + ['Unknown'] * (n-2) + ['W']
if s[0]  == 'x':
    ans[1] = 'S'
else:
    ans[1] = 'W'
loop()
if ans[n-1] == 'W':
    if (s[n-1] == 'x' and ans[n-2] == 'S') or (s[n-1] == 'o' and ans[n-2] == 'W'):
        print(''.join(ans))
        exit()

print(-1)


Measured memory_bytes: 6740
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
int a=Integer.parseInt(sc.next());
String op=sc.next();
int b=Integer.parseInt(sc.next());
if(op.equals("?") ){break; }
if(op.equals("-"))System.out.println(a-b);
if(op.equals("*"))System.out.println(a*b);
if(op.equals("/"))System.out.println(a/b);
if(op.equals("+"))System.out.println(a+b);

}
}
}


Measured memory_bytes: 26200
#include<iostream>
#include<iomanip>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
#include <functional>
#include <cassert>
typedef long long int ll;
using namespace std;

int main(){
	int A,B,C;
	cin>>A>>B>>C;
	if(A==7&&B==5&&C==5){
		cout<<"YES"<<endl;
		return 0;
	}
	if(B==7&&A==5&&C==5){
		cout<<"YES"<<endl;
		return 0;
	}
	if(C==7&&A==5&&B==5){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>
#include <array>

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

constexpr int N = 1e5;
char S[N+10], T[N+10];
std::array<short, N+1> vS, vT;
constexpr short K = 'A' - 1;

int main(void){
    // A -> BB -> AAAA ; ABBAA -> ABBB
    // A -> AAAA -> AAABB -> BB
    // つまり, A = BB = AAAA
    //        B = AA = BBBB   : 3文字 === 空文字列
    // BA -> BBB = 0 : A = 1, B = 2と置いた時ハッシュ値みたいになるのでは？
    scanf("%s%s", S, T);
    int n = strlen(S), m = strlen(T);
    vS[0] = 0; REP(i, n) vS[i+1] = (vS[i] + S[i] - K) % 3;
    vT[0] = 0; REP(i, m) vT[i+1] = (vT[i] + T[i] - K) % 3;
    int q; scanf("%d", &q);
    while(q--){
        int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); a--; c--;
        short sss = (vS[b] - vS[a] + 3) % 3;
        short ttt = (vT[d] - vT[c] + 3) % 3;
        puts(sss==ttt ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    int a;
    int N;
    //入力
    cin >> N;
    int num[N];


    for(int i=0; i<N; i++){
        cin >> a;
        num[a-1]=i+1;
    }

    //処理
    for(int i=0; i<N; i++, cout << " "){
        cout << num[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
const int MOD = 1000 * 1000 * 1000 + 7;
const int N =3000;

ll dp[N+1][N+1];

int main()
{


    int n;cin>>n;
    string s;cin>>s;

    for (int i = 1; i <= n; ++i)
    {
        dp[i][0] = 0;
    }
    dp[1][1] = 1;
    for (int i = 0; i < s.length(); ++i)
    {
        for (int j = 1; j <= i+2; ++j)
        {
            if(s[i] == '<')
                dp[i+2][j] = dp[i+1][j-1];
            else
                dp[i+2][j] = (dp[i+1][i+1]-dp[i+1][j-1]+MOD)%MOD;
        }

        for (int j = 2; j <= i+2; ++j)
        {
            dp[i+2][j] = (dp[i+2][j]+dp[i+2][j-1])%MOD;
        }
    }

    cout<<dp[n][n];
    return 0;
} 



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

int main() {
  ll n;
  cin >> n;
  vector<ll> A(n+1);
  ll sum=0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j +=i) {
      A.at(j)++;
    }
  }
  for (int i = 1; i <= n; i++) {
    sum +=i*A.at(i);
  }
    cout << sum << endl;
}

Measured memory_bytes: 81296
#include <stdio.h>

int main(void){
	int n, x, i;
	int flag;

	scanf("%d", &n);

	for(i = 1; i <= n; i++){
		x = i;
		flag = 0;

		do{
			if(x % 3 == 0){
				printf(" %d", i);
				flag = 2;
			} else
			do{
				if(x % 10 == 3){
					printf(" %d", i);
					flag = 2;
				}

				if(flag != 1){
					x /= 10;

					if(x == 0){
						flag = 2;
					}
				}
			}while (flag < 1);
		}while (flag < 2);
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 1820
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int b = sc.nextInt();
		
		long ans = (long)b * (long)Math.pow(b-1,(n-1));
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
#include<stdio.h>
int main(){
int a[1001],b,c,d,i,e,f;
while(1){
scanf("%d %d\n",&b,&c);
if(b==0 && c==0){
break;
}
for(i=1;i<=b;i++){
a[i]=0;
}
e=c;
d=b;
for(i=0;d>1;){
i=i+1;
if(i>b){
i=i-b;
}
if(a[i]==0){
e--;
if(e==0){
a[i]=1;
e=c;
d--;
}
}
}
for(i=1;i<=b;i++){
if(a[i]==0){
f=i;
}
}
printf("%d\n",f);
}
return 0;
}


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

int main(){

    int N;
    cin >> N;

    int A[N];

    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    
    int ans[N];

    for (size_t i = 0; i < N; i++)
    {
        ans[A[i]-1]=i;
    }
    
    for (size_t i = 0; i < N; i++)
    {
        cout << ans[i]+1 << " ";
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a, b) memset(a, b, sizeof(a))
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 200001;
const int mod = 1e9 + 7;
 
 
#define FILENAME ""

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
     //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
    ll a, b;
    cin >> a >> b;
    cout << max((ll) 0, a - 2*b);    
    return 0;
}

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

using namespace std;

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

  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int ans = 0;
  for (int i = 0; i <= min(k, n); i++) {
    for (int j = 0; j <= min(k, n); j++) {
      if (i + j > min(k, n)) continue;
      const int rem = k - i - j;
      priority_queue<int, vector<int>, greater<int>> q;
      int s = 0;
      for (int i2 = 0; i2 < i; i2++) {
        s += v[i2];
        q.push(v[i2]);
      }
      for (int j2 = 0; j2 < j; j2++) {
        s += v[n - 1 - j2];
        q.push(v[n - 1 - j2]);
      }
      for (int l = 0; l < rem; l++) {
        if (q.empty()) break;
        if (q.top() >= 0) break;
        s -= q.top();
        q.pop();
      }
      ans = max(ans, s);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 1) {
			System.out.println(n / 2 + 1);
		} else {
			System.out.println(n / 2);
		}
	}
}

Measured memory_bytes: 21844
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;

int main(){
    char A[20];
    scanf("%s", A);
    string a = A;
    string year = a.substr(0, 4);
    string month = a.substr(5, 2);
    string day = a.substr(8, 2);
    if(stoi(year)> 2019){
        printf("TBD\n");
        return 0;
    }else if (stoi(month) > 4){
        printf("TBD\n");
        return 0;
    }else if(stoi(month) >30){
        printf("TBD\n");
        return 0; 
    }else{
        printf("Heisei\n");
    }
    return 0;
}

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

typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
    
    ll k; cin>>k;
    if (k == 1){
        cout<<k<<'\n';
        return 0;
    }
    ll c = 7;
    ll curr = 0;
    ll pw = 1;
    for (ll i=1; i<=k; i++){
        curr += c * pw;
        curr %= k;
        if (curr == 0){
            cout<<i<<'\n';
            return 0;
        }
        pw *= (ll)10;
        pw %= k;
    }
    cout<<-1<<'\n';
	return 0;
}
/*
NARCO
*/


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m;
	cin >> n >> m;
	ll a[n], g[2*m], cnt[2*m];
	zep(i, 0, n){cin >> a[i]; a[i]--;}
	
	ll up = 0;
	memset(g, 0, sizeof(g));
	memset(cnt, 0, sizeof(cnt));
	zep(i, 1, n){
		ll tmp = (a[i]+m-a[i-1])%m;
		up += tmp;
		g[a[i]+m] += tmp;
		cnt[a[i]+m]++;
		cnt[a[i]+m-tmp]--;
	}
	
	//ll fr[2*m];
	ll num = 0;
	//memset(fr, 0, sizeof(fr));
	rrep(i, 2*m-1, 1){
		num += cnt[i];
		g[i] -= num;
		//fr[i] += g[i];
		if(i > 0){
			g[i-1] += g[i];
		}
	}
	//printa(g, 0, 2*m-1)
	//printa(cnt, 0, 2*m-1)
	//printa(fr, 0, 2*m-1)
	ll ans = INF;
	zep(i, 0, m){
		ans = min(up-g[i]-g[i+m], ans);
	}
	print(ans)
	return 0;
}

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

int main()
{
    string day ;
    int x ;
    cin >> day ;

    if(day=="SAT")
        x=0;
    else if(day=="SUN")
        x=1;
    else if(day=="MON")
        x=2;
    else if(day=="TUE")
        x=3;
    else if(day=="WED")
        x=4;
    else if(day=="THU")
        x=5;
    else if(day=="FRI")
        x=6;

    if (x<1)
    {
        cout<<1-x;
    }
    else
        cout<<7-x+1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    int l=a.size();
    int m=b.size();
    char n=a.at(l-1);
    char o=b.at(0);
    char p=b.at(m-1);
    char q=c.at(0);
    if(n==o&&p==q){puts("YES");}
    else{puts("NO");}
    return 0;}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var A = Sarray()[0];
            var B = Sarray()[0];
            var C = Sarray()[0];
            var D = Sarray()[0];
            WriteLine(Min(A, B) + Min(C, D));
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28160
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
 
            int count = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i % 2 == 1 && DivisorsNum(i))
                {
                    count++;
                }
            }
 
            Console.WriteLine(count);
        }
 
        public static bool DivisorsNum(int N)
        {
            int count = 0;
            for (int i = 1; i <= N; i++)
            {
                if(N%i == 0)
                {
                    count++;
                }
                if(count > 8) return false;
            }
            
            if(count ==8) return true;
            else return false;
        }
    }
}

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

if n == 0:
    print(0)
else:
    cnt, now = 1, 0
    ans = ''
    for i in range(100):
        if n == now:
            break
        if (n - now) % (2**(i + 1)) != 0:
            ans = ans + '1'
            now += pow(-2, i)
        else:
            ans = ans + '0'
    print(ans[::-1])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=200009;
bool qw[MAX_N];

struct unionfind{
  int par[MAX_N];
  int myrank[MAX_N];
  int size[MAX_N];
  void init(int n){
    for(int i=1;i<=n;i++){par[i]=i; myrank[i]=0; size[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(myrank[x]<myrank[y]){par[x]=y; size[y]+=size[x];}
    else{par[y]=x; size[x]+=size[y];}
    if(myrank[x]==myrank[y]){myrank[x]++;}
  }
  bool same(int x, int y){return find(x)==find(y);}
};

int main(){
  int N,K,L;
  cin >> N >> K >> L;
  vector<int> p(K),q(K),r(L),s(L);
  for(int i=0;i<K;i++)cin >> p[i] >> q[i];
  for(int i=0;i<L;i++)cin >> r[i] >> s[i];
  unionfind D,R,W;
  D.init(N); R.init(N); W.init(N);
  for(int i=0;i<K;i++){D.unite(p[i],q[i]);}
  for(int i=0;i<L;i++){R.unite(r[i],s[i]);}
  vector<pair<int,int>> pa(N);
  for(int i=1;i<=N;i++){pa[i-1]=make_pair(D.find(i),R.find(i));}
  sort(pa.begin(),pa.end());
  map<pair<int,int>,int> ma;
  for(int i=0;i<N;i++){
    int cnt=1;
    while(i+1<N && pa[i].first==pa[i+1].first && pa[i].second==pa[i+1].second){
      i++; cnt++;
    }
    ma[make_pair(pa[i].first,pa[i].second)]=cnt;
  }
  for(int i=1;i<=N;i++){
    cout << ma[make_pair(D.find(i),R.find(i))] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 19712
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define freopen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define freopen //comment
#endif
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define pb push_back
typedef tree<int, null_type,less<int>,  rb_tree_tag,tree_order_statistics_node_update>  ordered_set;
#define int long long int
#define endl "\n"
main()
{ 
// freopen
 io
 int n;
 cin>>n;
 int a[n+1];
 for(int i=0;i<n;i++)
 {
  cin>>a[i];
 }
 int ans=0,start=a[0];
 for(int i=1;i<n;i++)
 {
   if(start>a[i])
   {
    ans+=start-a[i];
    a[i]=start;
   }
   start=max(start,a[i]);
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 5168
#include <stdio.h>

int main(void) {
	int i, n, a, b = -1, cnt = 0, ans = 0;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		if (b == a) {
			cnt++;
		} else {
			ans += (cnt+1) / 2;
			cnt = 0;
		}
		b = a;
	}
	
	ans += (cnt+1) / 2;
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static String input;
    public static void main(String[] args) {
        while(read()){
            slove();
        }
    }
    static  boolean read(){
        if(!sc.hasNext())return false;
        input = sc.nextLine();
        return true;
    }
    static void slove(){
        String res = new StringBuffer(input).reverse().toString();
        System.out.println(res);
        //res = new StringBuffer("1234gtt").reverse().toString();
        //System.out.println(res);
    }
}

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

using namespace std;

int main () {

  int n, el, count = 0;
  cin >> n;

  for(int i = 0; i < n; i ++) {
    cin >> el;
    while(el % 2 == 0) {
      el /= 2;
      count ++;
    }
  }

  cout << count << endl;

  return 0;
}

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

using namespace std;

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 9;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e9) return 10;
  if (x >= (long long)1e8) return 9;
  if (x >= (long long)1e7) return 8;
  if (x >= (long long)1e6) return 7;
  if (x >= (long long)1e5) return 6;
  if (x >= (long long)1e4) return 5;
  if (x >= (long long)1e3) return 4;
  if (x >= (long long)1e2) return 3;
  if (x >= (long long)1e1) return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char& c) { c = buf_in[pt_in++]; }
template <class T>
inline void scan(T& x) {
  if (pt_in + 32 > tail_in) load();
  char c;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T>
inline void print(T x) {
  if (pt_out > buf_size - 32) flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char* s) {
  for (int i = 0; s[i] != 0; ++i) print(s[i]);
}
template <class T>
inline void println(T x) {
  print(x);
  print('\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
}  // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int ct = 0;
  for (int i = 0; i < N; ++i) {
    int l, r;
    scan(l);
    scan(r);
    if (l == r) {
      ct++;
      if (ct >= 3) {
        println("Yes");
        return 0;
      }
    } else {
      ct = 0;
    }
  }
  println("No");
  return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<int,ll> p;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;

int n,m;
int s,t;
vector<vector<p> > Ga,Gb;
vector<ll> da,db;
void dijkstra(vector<vector<p> > G,vector<ll> &d,int s){
    priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> > > que;
    d[s]=0;
    que.push(make_pair(d[s],s));
    while(!que.empty()){
        auto p=que.top();que.pop();
        ll dis=p.first;
        int u=p.second;
        if(dis>d[u]) continue;
        for(auto e:G[u]){
            int v=e.first;
            ll cost=e.second;
            if(d[v]>d[u]+cost){
                d[v]=d[u]+cost;
                que.push(make_pair(d[v],v));
            }
        }
    }
}
int main(){
    cin>>n>>m>>s>>t;
    s--;t--;
    Ga=Gb=vector<vector<p> >(n);
    for(int i=0;i<m;++i){
        int u,v,a,b;cin>>u>>v>>a>>b;
        u--;v--;
        Ga[u].push_back(p(v,a));
        Ga[v].push_back(p(u,a));
        Gb[u].push_back(p(v,b));
        Gb[v].push_back(p(u,b));
    }
    da=db=vector<ll>(n,INF);
    dijkstra(Ga,da,s);
    dijkstra(Gb,db,t);
    vector<ll> mm(n+1,INF);
    for(int i=n-1;i>=0;--i){
        mm[i]=min(mm[i+1],da[i]+db[i]);
    }
    for(int i=0;i<n;++i){
        cout<<1000000000000000-mm[i]<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int W, a, b;
	cin >> W >> a >> b;

	if (abs(a - b) <= W) {
		cout << 0 << endl;
	}
	else {
		cout << abs(a - b) - W << endl;
	}

	return 0;

}

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

int main() {
  string s; cin >> s;
  vector<int> wpos;
  long long int ans = 0, last = (int)s.size() - 1;

  for(int i = 0;i <= last;i++) {
    if(s[i] == 'B') wpos.push_back(i);
  }

  for(int i = (int)wpos.size() - 1;i >= 0;i--) {
    ans += last - wpos[i];
    last--;
  }

  cout << ans << endl;
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int g[8][8];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a][b] = 1;
        g[b][a] = 1;
    }
    vi p(n-1);
    rep(i, n-1) p[i] = i + 1;
    int ans = 0;
    do {
        bool ok = true;
        int now = 0;
        rep(i, n-1) {
            if (!g[now][p[i]]) ok = false;
            now = p[i];
        }
        if (ok) ++ans;
    } while (next_permutation(all(p)));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
list = []


for i in range(n):
    a,b = map(int,input().split())
    list.append([a,b])

list = sorted(list)

quantity = 0
ans = 0

while quantity < m:
    value = list.pop(0)
    ans,quantity = ans+(value[0]*value[1]),quantity+value[1]

if quantity > m:
    temp = quantity-m
    ans = ans-temp*value[0]

print(ans)


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

int main(void){
    int x,a,b;
    cin>>x>>a>>b;
    if(a>=b) cout<<"delicious"<<endl;
    else if(b-a<=x) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN],x[MAXN],y[MAXN];
set<P> s;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) 
    {
        scanf("%d%d",&x[i],&y[i]);
        s.insert(P(x[i],y[i]));
    }
    int ans=n;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int p=x[j]-x[i],q=y[j]-y[i];
            int cnt=0;
            for(int k=1;k<=n;k++)
                if(!s.count(P(x[k]+p,y[k]+q))) cnt++;
            ans=min(ans,cnt);
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<ll> b(m);
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i];
    vl ans = convolution(a, b);
    REP(i, n + m - 1) cout << ans[i] << " ";
    cout << endl;
}


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

int main() {
	int n; cin >> n;
	queue<int> t, x, y;
	rep(i, 0, n) {
		int T, X, Y;
		cin >> T >> X >> Y;
		t.push(T); x.push(X); y.push(Y);
	}

	string ans = "Yes";
	int nx = 0, ny = 0;
	bool f = 0;
	rep(i, 1, t.back() + 1) {
		if (nx != x.front()) {
			if (nx < x.front()) nx++;
			else nx--;
		}
		else if (ny != y.front()) {
			if (ny < y.front()) ny++;
			else ny--;
		}
		else nx++;
		if (i == t.front()) {
			if (nx == x.front() && ny == y.front()) {
				t.pop(); x.pop(); y.pop();
			}
			else {
				ans = "No";
				break;
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}

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

int main(void){
	int a=0,b=0,o=0,ab=0;
	int tmp;
	string str;
	while(cin >> tmp){
		cin.ignore();
		cin >> str;
		if(str == "A") a++;
		if(str == "B") b++;
		if(str == "O") o++;
		if(str == "AB") ab++;
	}
	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;
}

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

struct In{
	int a, b, c, d;
};

int ans = 0;
vi A;
void dfs(int &m, int &n, int depth, vector<In> &in, int &q){
	if(depth == n+1){
		int res = 0;
		for(int i = 0; i < q; i++){
			if(A[in[i].b] - A[in[i].a] != in[i].c) continue;
			res += in[i].d;
		}
		ans = max(ans, res);
		return;
	}
	for(int i = 1; i <= m; i++){
		if(A[depth-1] > i) continue;
		A[depth] = i;
		dfs(m, n, depth+1, in, q);
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, m, q;
	cin >> n >> m >> q;
	vector<In> in(q);
	vi c(q), d(q);
	rep(i, q)
		cin >> in[i].a >> in[i].b >> in[i].c >> in[i].d;

	A.resize(n+1, 1);
	dfs(m, n, 1, in, q);

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
 
using namespace std;
 
int main()
{
  long long a,b,d; cin>>a>>b;
  char c;cin>>c;
  cin>>d;
  
  b = (b*100)+d;
  
  long long res = (a*b)/100;
  
  cout<<res;
  
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);

int main(){
    ll h;
    cin>>h;
    ll ans=0,d=1;
    while(h>=1){
        h/=2;
        ans+=d;
        d*=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    string s = Console.ReadLine();
    int count = 0;

    if(s[0] == '1')count++;
    if(s[1] == '1')count++;
    if(s[2] == '1')count++;

    Console.WriteLine(count.ToString());
  }
}

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

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int y = sc.nextInt();
		
		
		for(int i = 0; i <= n; i++) {
			for(int k = 0; k <= n-i; k++) {
				
				int j = n - (i + k);
				
				if(y == (i * 10000) + (k * 5000) + (j * 1000)) {
					System.out.println(i + " " + k  + " "  + j);
					System.exit(0);
				}	
			}
		}

		System.out.println("-1 -1 -1");
	}

}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;


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

	int ans=0;
	while (1) {
		bool flag=false;
		for (int i = 0; i < N; i++) {
			if (i == 0 && h[i]!=0) {
				ans++;
				flag = true;
			}
			if (h[i] > 0) {
				if (!flag) {
					ans++;
					flag=true;
				}
				h[i]--;
			}
			else if (h[i] == 0) {
				flag=false;
			}
		}
		bool F=true;
		for (int i = 0; i < N; i++) {
			if(h[i]!=0) F=false;
		}
		if(F) break;
	}

	cout << ans << endl;

}
	


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<bits/stdc++.h>
#include<string>
#include<cmath>
using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  cout<<(3*A+B)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a[200010];
int memo[1000010],x[1000010],y[1000010],cnt[1000010];
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i=1;i<=1000000;i++){
        for(int j=1;i*j<=1000000;j++){
            x[i]+=(i*j)*cnt[(i*j)];
            y[i]+=(i*j)*(i*j)%mod*cnt[(i*j)]%mod;
            x[i]%=mod;
            y[i]%=mod;
        }
    }
    for(int i=1;i<=1000000;i++){
        x[i]*=x[i];
        x[i]%=mod;
    }
    int ans=0;
    for(int i=1000000;i>=1;i--){
        int memosum=0;
        for(int j=1;i*j<=1000000;j++){
            memosum+=memo[i*j];
            memosum%=mod;
        }
        int res=(x[i]-y[i]+mod)%mod*inv(2)%mod;
        res=(res-memosum+mod)%mod;
        ans+=res*inv(i)%mod;
        ans%=mod;
        memo[i]=res;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 5*1e5;
vector<vector<char>> grid;
vector<vector<char>> tmp;
int h, w, k;

void do_paint(int i, int j){
    for(int x=0; x<h; x++){
        if((i>>x)&1){
            for(int y=0; y<w; y++)
                tmp[x][y] = 'R';
        }
    }

    for(int x=0; x<w; x++){
        if((j>>x)&1){
            for(int y=0; y<h; y++)
                tmp[y][x] = 'R';
        }
    }
}

int do_count(){
    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(tmp[i][j]=='#')
                ans++;
        }
    }
    return ans;
}


int main(){
    AC
    cin>>h>>w>>k;
    grid.resize(h);
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin>>c;
            grid[i].push_back(c);
        }
    }

    int ans = 0;
    for(int i=0; i<(1<<h); i++){
        for(int j=0; j<(1<<w); j++){
            //cout<<i<<" "<<j<<endl;
            tmp = grid;
            do_paint(i, j);
            if(do_count()==k)
                ans++;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3572
import java.util.*;
import java.io.*;

public class Main {
  
   public static void main(String []abc){
      Main sol = new Main();
      long answer = sol.solve();
      System.out.println(answer);
   }
  
  private long solve() {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     long [] array = new long [N];
     for(int i=0;i<N;i++) {
        array[i] = sc.nextLong();
     }
     long dp[] = new long[N+1];
     for(int i=0;i<N;i++) {
       if (i==0) dp[i]=0;
       else if (i==1) dp[i] = Math.abs(array[i]-array[i-1]);
       else {
         dp[i] = Math.min(dp[i-1]+ Math.abs(array[i]-array[i-1]), dp[i-2]+Math.abs(array[i]-array[i-2]));
       }
       //System.out.printf("dp[%d]: %d\n", i, dp[i]);
     }      
     return dp[N-1];
  }
         
}
    
    


Measured memory_bytes: 59512
#include <iostream>

using namespace std;

bool even(int n) {
    if (n % 2 == 0) return true;
    return false;
}

int count(int n, int acc) {
    if (n==1) return acc;
    if (even(n)) {
        return count(n/2, acc+1);
    }
    return count(n*3+1, acc+1);
}

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        cout << count(n, 0) << endl;
    }
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

const int MAX_N = 110000;

int dp[MAX_N]; // memo[i]がiについての答え

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < MAX_N; i++)
        dp[i] = N;
    dp[0] = 0;

    // もらうDP
    for (int n = 1; n <= N; n++) {
        for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
            dp[n] = min(dp[n], dp[n - pow6] + 1);
        }
        for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
            dp[n] = min(dp[n], dp[n - pow9] + 1);
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 4064
N = int(input())
flag = False
for n in range(1,3501):
    if flag:
        break
    for h in range(1,3501):
        if flag:
            break
        if 4*h*n-N*n-N*h > 0:
            if (N*n*h)%(4*h*n-N*n-N*h) == 0:
                print(h,n,(N*n*h)//(4*h*n-N*n-N*h))
                flag = True

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
long long moduloMultiplication(long long a,
                               long long b,
                               long long mod)
{
    long long res = 0; // Initialize result

    // Update a if it is more than
    // or equal to mod
    a %= mod;

    while (b)
    {
        // If b is odd, add a with result
        if (b & 1)
            res = (res + a) % mod;

        // Here we assume that doing 2*a
        // doesn't cause overflow
        a = (2 * a) % mod;

        b >>= 1; // b = b / 2
    }

    return res;
}
int main()
{
    int x;
    cin >> x;
    if (x == 0)
    {
        cout << "1";
    }
    else
    {
        cout << "0";
    }
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(){
  int H,W,i,j;
  for(;;){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    for(j=1;j<=H;j++){
      for(i=1;i<=W;i++){
        if((i+j)%2 ==0){
          printf("#");
        }else {
          printf(".");
        } 
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2100