akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<string>
using namespace std;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

signed main()
{
  int n;cin >> n;
  vector<int> a(0);
  int b;
  while(cin >> b){
    a.emplace_back(b);
  }
  int ans = 0;

  for(size_t i = 0; i < n; ++i){
      while(i+1 < n && a[i] == a[i+1]) ++i;

      if(i+1 < n && a[i] < a[i+1])
          while(i+1 < n && a[i] <= a[i+1]) ++i;

      else if(i+1 < n && a[i] > a[i+1])
          while(i+1 < n && a[i] >= a[i+1]) ++i;
      ++ans;
  }
    cout << ans << endl;
  
	return 0;
}

    /*
    while(i+1 < n){//not i < n
      // <= にしてたら困ったので <, =, >で分ける
      
      while(a[i] <= a[i+1]) ++i;
      ++ans;++i;cout << "a" << i << endl;
      while(a[i] >= a[i+1]) ++i;
      ++ans;++i;cout << "b" << i << endl;
      でやるとansが
      
      if(a[i] <= a[i+1]){
        while(a[i] <= a[i+1]) ++i;
        ++ans;cout << "a" << i << endl;
      }//cout << "c" << i << endl;
      if(a[i] >= a[i+1]){
        while(a[i] >= a[i+1]) ++i;
        ++ans;cout << "b" << i << endl;
      }
    }
  }*/

  /*
   for(auto itr: a){
    cout << itr;
  } 
  */

Measured memory_bytes: 892
#include<iostream>

using namespace std;

int selectionSort(int A[], int N){
    int minj, sw = 0;
    for(int i = 0; i < N; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i != minj){
            swap(A[i], A[minj]);
            sw++;
        }
    }
    for(int i = 0; i < N; i++){
        if(i)cout << " ";
        cout << A[i];
    }
    cout << endl;

    return sw;
}

int main(){
    int N, sw;
    cin >>N;
    int A[N];
    for(int i = 0; i < N; i++)cin >>A[i];
    sw = selectionSort(A, N);
    cout << sw << endl;

    return 0;

}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,i,ans;
    long long int sum=0,shakkin=0;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(i=0;i<n;i++){
        cin >> a.at(i); 
    }
    for(i=0;i<n;i++){
        cin >> b.at(i);
        c.at(i) = a.at(i)-b.at(i);
        sum += c.at(i);
        if(c.at(i)<0){
            shakkin -= c.at(i);
            ans++;
            c.at(i)=0;
        }
    }
    if(sum < 0){
        cout << "-1" << endl;
        return 0;
    }
    sort(c.begin(),c.end());
    i=n-1;
    while(shakkin>0){
        ans++;
        shakkin -= c.at(i);
        i--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {

    lli N;
    cin >> N;

    vector<string> history(N);

    bool flag = true;
    for (int i = 0; i < N; ++i) {
        string w;
        cin >> w;

        if (i == 0) {
            history[0] = w;
            continue;
        }

        string beforeLast = history[i - 1];
        beforeLast = beforeLast.substr(beforeLast.size() - 1, 1);

        string first = w.substr(0, 1);

        if (beforeLast != first) {
            flag = false;
            break;
        }

        auto result = find(history.begin(), history.end(), w);
        if (result != history.end()) {
            // found
            flag = false;
            break;
        }

        history[i] = w;
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import defaultdict


N = int(input())
A = list(map(int, input().split()))

dic = defaultdict(int)

for i in range(len(A)):
    dic[A[i]] += 1

for i in range(1, N+1):
    if i in dic:
        print(dic[i])
    else:
        print(0)

Measured memory_bytes: 116824
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int n,m,x,inf=1e8,r=inf;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;++i){
        cin>>c[i];
        for(int& p:a[i])
            cin >> p;
    }

    for(int i=0;i<(1<<n);++i){
        vector<int> cprh(m, 0);
        int cost = 0;
        for (int j = 0; j < n; ++j)
        {
            if((i>>j)&1){
                cost += c[j];
                for (int k = 0; k < m; ++k)
                    cprh[k] += a[j][k];
            }
        }
        for(int j=0;j<m;++j){
            if(cprh[j]<x){
                cost = inf;
                break;
            }
        }
        r = min(r, cost);
    }
    if(r==inf)r=-1;
    cout << r;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

    if(x-r<0||x+r>W){
    printf("No\n");
    }

    else if(y-r<0||y+r>H){
    printf("No\n");
    }

    else if(x-r>=0&&x+r<=W){
    printf("Yes\n");
    }

    else if(y-r>=0&&y+r<=H){
    printf("Yes\n");
    }





return 0;
}

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

using namespace std;

int main() {
    vector<int> A(3);
    for(int i=0; i<3; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    
    int ans=0;
    int mx=A[2]-A[0];
    int mn=A[2]-A[1];
    ans += mx/2;
    ans += mn/2;
    
    if(mx%2==1 && mn%2==1) {
        ans++;
    } else if(!(mx%2==0 && mn%2==0)) {
        ans+=2;
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n: usize);
    let mut dp = [[0i64; 10]; 10];
    let mut tot = 0;
    for i in 1..n + 1 {
        let mut v = i;
        let mut seq = vec![];
        while v > 0 {
            seq.push(v % 10);
            v /= 10;
        }
        dp[seq[0]][seq[seq.len() - 1]] += 1;
    }
    for i in 0..10 {
        for j in 0..10 {
            tot += dp[i][j] * dp[j][i];
        }
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

long long f(priority_queue<pair<int, int>>& pq){
  long long sum = 0;
  while(!pq.empty() && sum + pq.top().first >= 0){
    sum += pq.top().second;
    pq.pop();
  }
  
  if(pq.empty()) return sum;
  else return -1;
}

int main(){
  int N;
  cin >> N;
  
  priority_queue<pair<int, int>> pqa, pqd;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    int b = 0, c = 0;
    for(char ch : S){
      if(ch == '(') ++c;
      else --c;
      b = min(c, b);
    }
    
    if(c >= 0) pqa.push(make_pair(b, c));
    else pqd.push(make_pair(b - c, -c));
  }
  
  long long suma = f(pqa), sumd = f(pqd);
  if(suma >= 0 && suma == sumd) puts("Yes");
  else puts("No");
  
  return 0;
}

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

int main(){
  int a,b;
  string s;
  cin >> a >> b;
  cin >> s;
  int count=0;
  if(s.at(a)!='-'){
    count++;
  }
  for(int i=0;i<a;i++){
    if(s.at(i)=='-'){
      count++;
    }
  }
  for(int i=a+1;i<a+b+1;i++){
    if(s.at(i)=='-'){
      count++;
    }
  }
  if(count==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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

string s;


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    sf(s);
    if (s == "Sunny") {
        cout << "Cloudy";
    }else if (s == "Cloudy") {
        cout << "Rainy";
    }else {
        cout << "Sunny";
    }

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

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

using namespace std;

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int l, r;
   cin >> l >> r;
   if(r - l >= 2019) {
       cout << 0 << endl;
       return 0;
   } else {
       long long ans = 2018;
       for(int i = l; i < r; i++) {
           for(int j = i + 1; j <= r; j++) {
               ans = min(ans, (long long) i * (long long) j % 2019);
           }
       }
       cout << ans << endl;
   }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	int pre = 0;
	set<int> s;
	for(int i = 0; i < k; ++i)
	{
		int cur = (pre*10+7)%k;
		if(cur == 0)
		{
			cout << i+1;
			return 0;
		}
		if(s.find(cur) == s.end())
		{
			s.insert(cur);
		}
		else
		{
			cout << -1;
			break;
		}
		pre = cur;
	}

	return 0;
}

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

int main() {
	string a, b;
	cin >> a >> b;
	int n = (int) a.size();
	map<char, char> mp;
	for(int i = 0; i < n; ++i) {
		char x = a[i];
		char y = b[i];
		if(mp.count(x) and mp[x] != y) {
			cout << "No";
			return 0;
		} 
		mp[x] = y;
	}
	int cnt[500]{0};
	for(auto& c: mp) ++cnt[c.second];
	for(int i = 0; i < 500; ++i) {
		if(cnt[i] > 1) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


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

char p[9][9],m[9][9];

void vertical(int ti,int tj){
	for(int i=ti+1;i<9;i++)
		if(p[ti][tj] == p[i][tj])
			m[ti][tj] = m[i][tj] = '*';
}

void horizontal(int ti,int tj){
	for(int j=tj+1;j<9;j++)
		if(p[ti][tj] == p[ti][j])
			m[ti][tj] = m[ti][j] = '*';
}

void square(int ti,int tj){
	for(int k=(ti%3)*3+tj%3+1;k<9;k++){
		int i=ti/3*3+k/3, j=tj/3*3+k%3;
		if(p[ti][tj] == p[i][j])
			m[ti][tj] = m[i][j] = '*';
	}
}

int main(void){
	int i,j,n,set;

	cin>>n;
	for(set=0;n--;set++){
		if(set!=0) cout<<endl;
		for(i=0;i<9;i++){
			for(j=0;j<9;j++){
				cin>>p[i][j];
				m[i][j] = ' ';
			}
		}

		for(i=0;i<9;i++){
			for(j=0;j<9;j++){
				vertical(i,j);
				horizontal(i,j);
				square(i,j);

				cout<<m[i][j];
				cout<<p[i][j];
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();

        System.out.println(solve(N));
    }

    private static int solve(int N) {
        int count = N * (1 + N )/2;

        return count;
    }
}

Measured memory_bytes: 23124
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>
#include<math.h>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;
const int INF=100000000;
int main(){
  int n;
  while(cin>>n,n!=0){
    int dp[100][100];
    rep(i,10){
      rep(j,10){
	dp[i][j]=i==j?0:INF;
      }
    }
    int k[100]={};
    vector<int> vec;
    rep(i,n){
      int a,b,c;
      cin>>a>>b>>c;
      dp[a][b]=c;
      dp[b][a]=c;
      k[a]++;
      k[b]++;
    }
    int city=0;
    rep(i,11){
      if(k[i]>0){
	city++;
	vec.push_back(i);
      }
    }
    rep(k,10){
      rep(i,10){
	rep(j,10){
	  dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
	}
      }
    }
    int minsum=INF,num;
    rep(i,vec.size()){
      int sum=0;
      rep(j,vec.size()){
	sum+=dp[vec[i]][vec[j]];
      }
      if(minsum>sum){
	minsum=sum;
	num=vec[i];
      }    
    }
    cout<<num<<" "<<minsum<<endl;
  }
  return 0;
}
     

Measured memory_bytes: 3128
from collections import Counter

n, k = map(int, input().split())
a = list(map(int, input().split()))

c = Counter(a) # Counter({1: 2, 2: 2, 5: 1})
count = c.values() # [2, 2, 1] (type: 'dict_values')

l_count = list(count) # to list 
l_count.sort(reverse = True) # to descending order

print(n - sum(l_count[:k])) # n - (sum of first k values from count[])


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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define PB push_back
#define MP make_pair
#define MOD 1000000000
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)

typedef unsigned int UI;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<char, int> PCI;
int n , k;
vector<vector<int> > g(2000);
int dist[2000][2000];
void dfs(int u , int from , int p = -1)
{
	for(int i = 0; i < g[u].size(); i++)
	{
		int v = g[u][i];
		if(v != p)
		{
			dist[from][v] = dist[from][u] + 1;
			dfs(v , from , u);
		}
	}
}
int cannotBe[2000];
int main()
{
	//freopen("input.txt" , "r" , stdin);
	scanf("%d %d" , &n , &k);
	for(int i = 1; i < n; i++)
	{
		int u , v;
		scanf("%d %d" , &u , &v);
		u--;v--;
		g[u].pb(v);
		g[v].pb(u);
	}
	//cout << n << endl;
	for(int i = 0; i < n; i++)
	{
		dfs(i , i);
	}
	vector<set<int> >gr(n);
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dist[i][j] > k)
			{
				gr[i].insert(j);
			}
		}
	}

	int ans = 0;
	while(1)
	{
		int bestVert = -1;
		for(int i = 0; i < n; i++)
		{
			if((!cannotBe[i] && gr[i].size() > gr[bestVert].size()) || (!cannotBe[i] && gr[i].size() && bestVert == -1))
			{
				bestVert = i;
			}
		}
		if(bestVert == -1)
			break;
		cannotBe[bestVert] = 1;
		for(auto it = gr[bestVert].begin(); it != gr[bestVert].end(); it++)
		{
			gr[*it].erase(bestVert);
		}
		ans++;
	}
	/*for(int i = n - 1; i >= 0; i--)
	{
		int idx = szIdx[i].second;
		//cout << idx << endl;
		if(gr[idx].size())
		{
			ans++;
			for(auto it = gr[idx].begin(); it != gr[idx].end(); it++)
			{
				int v = *it;
				gr[v].erase(idx);
			}
		}
		szIdx.clear();
		for(int i = 0; i < n; i++)
		{
			szIdx.pb(mp(gr[i].size() , i));
		}
		sort(szIdx.begin() , szIdx.end());

	}*/
	cout << ans;
    return 0;
}


Measured memory_bytes: 205312
def main():
    N = int(input())
    S = ['$'] + list(input())

    c = lambda x: ord(x) - ord('a')
    bit = [BinaryIndexedTree(N) for _ in range(26)]
    for i, l in enumerate(S):
        if i == 0: continue
        bit[c(l)].add(i, 1)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            a = int(a)
            bit[c(S[a])].add(a, -1)
            bit[c(b)].add(a, 1)
            S[a] = b
        else:
            a, b = int(a), int(b)
            ans = 0
            for i in range(26):
                t = bit[i].sum(b)
                if a >= 1: t -= bit[i].sum(a-1)
                ans += 1 if t else 0
            print(ans)

class BinaryIndexedTree:
    def __init__(self, n=None, f=lambda x,y:x+y, zero=0, initial_values=None):
        assert(n or initial_values)
        self.__f, self.__z, = f, zero
        self.__n = n if n else len(initial_values)
        self.__dat = [zero] * (self.__n + 1)
        if initial_values:
            for i in range(1, self.__n + 1): self.add(i, initial_values[i-1]) #slow

    def add(self, i, v):
        while i <= self.__n:
            self.__dat[i] = self.__f(self.__dat[i], v)
            i += -i&i

    def sum(self, r):
        ans = self.__z
        while r:
            ans = self.__f(ans, self.__dat[r])
            r -= -r&r
        return ans

if __name__ == '__main__':
    main()


Measured memory_bytes: 167652
s = input()
ans = 1000
for i in range(len(s)-2):
    if ans >= abs( int(s[i])*100 + int(s[i+1])*10 + int(s[i+2]) - 753):
        ans = abs( int(s[i])*100 + int(s[i+1])*10 + int(s[i+2]) - 753)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
bool check(LL x){
	bool a=false;
	bool b=false;
	bool c=false;
	bool d=true;
	//cout<<x<<" ";
	while(x!=0){
		LL y=x%10;
		x/=10;
		//cout<<a<<" ";
		if(y==3){
			a=true;
		}else if(y==5){
			b=true;
		}else if(y==7){
			c=true;
		}else{
			d=false;
		}
	}
	bool e=a&b&c&d;
	//cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
	return a&b&c&d;
}

LL dfs(LL N,LL x){
	LL ans=0;
	if(x>N){
		return 0;
	}
	if(check(x)){
		ans++;
	}
	//cout<<x<<endl;
	ans+=dfs(N,x*10+3);
	ans+=dfs(N,x*10+5);
	ans+=dfs(N,x*10+7);
	return ans;
}

int main(){
	LL N;
	cin>>N;
	LL ans=0;
	ans+=dfs(N,3);
	ans+=dfs(N,5);
	ans+=dfs(N,7);
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int n, m;
int dp[N];
int mark[N];

int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int x;
		cin >> x;
		mark[x] = 1;
	}
	dp[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		if(mark[i])
			dp[i] = 0;
		else
		{
			dp[i] = dp[i - 1];
			if(i >= 2)
				dp[i] += dp[i - 2];
		}
		dp[i] %= MOD;
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
int main(void){

	while(1){
		int n,l,r;
		int count=0;
		int a[4001];
		bool flag=false;

		cin>>n>>l>>r;
		if(n==0){
			break;
		}
		FOR(i,1,n){
			cin>>a[i];
		}

		FOR(i,l,r){
			flag=false;

			FOR(j,1,n){
				if(i%a[j]==0){
					if(j%2==1){
						flag=true;
						count++;
					}else{
						flag=true;
					}
					break;
				}
			}
			if(flag==false){
				if(n%2==0){
					count++;
				}
			}
		}

		cout<<count<<endl;
		
	}

}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N, K;
	cin >> N >> K;
	int A; // tmp
	vector<int> map(200005, 0);

	rep(i, N) {
		cin >> A;
		map[A]++;
	}
	sort(map.begin(), map.end());
	reverse(map.begin(), map.end()); //降順
	ll ans = 0;
	for(int i=K; i<map.size(); i++) {
		ans += map[i];
		if(map[i]==0) break;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

class UnionFindTree {
    std::vector<int> tree;
public:
    UnionFindTree(size_t n): tree(n, -1) {}
    size_t find_root(size_t v) {
        if (tree[v] < 0) return v;
        return tree[v] = find_root(tree[v]);
    }
    bool unite(size_t x, size_t y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return false;
        if (rank(x) < rank(y)) std::swap(x, y);
        tree[x] += tree[y];
        tree[y] = x;
        return true;
    }
    bool connected(size_t x, size_t y) {
        return find_root(x) == find_root(y);
    }
    size_t rank(size_t v) {
        return -tree[find_root(v)];
    }
};

int main(){
  int N,M;cin>>N>>M;
  int P[N];
  REP(n,0,N){
    int tmp;cin>>tmp;
    P[n]=tmp-1;
  }
  int X[M],Y[M];
  REP(m,0,M){
    int x,y;cin>>x>>y;
    X[m]=x-1;Y[m]=y-1;
  }
 UnionFindTree tree(N);
 REP(i,0,M){
   tree.unite(X[i],Y[i]);
 }
 int ans=0;
 REP(i,0,N){
   if(tree.connected(P[i],i)){
     ans++;
   }
  }
  print(ans)
}


Measured memory_bytes: 1792
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] first = splitInt(sc.nextLine(), " ");
		int[] second = splitInt(sc.nextLine(), " ");
		
		int i= 1;
		int j = first[0]-2;
		int a = second[0];
		int b = second[first[0]-1];
		for(; i<first[0] && j>=0 && i<=j;) {
			if(a>b) {
				b += second[j];
				j--;
			}else {
				a += second[i];
				i++;
			}
		}
		System.out.println(Math.abs(a-b));
	}
	public static int[] splitInt(String str, String split) {
		String[] array = str.split(split);
		int[] array2 = new int[array.length];
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		return array2;
	}
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
	f = 0; _T fu = 1; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
	while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
	f *= fu;
}

template <typename T>
void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

const int N = 105, md = 998244353;

inline int add(int x, int y) {
	x += y;
	if (x >= md) x -= md;
	return x;
}

inline int sub(int x, int y) {
	x -= y;
	if (x < 0) x += md;
	return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

map <vector <int>, int> wxw;
vector <int> a;
char c[N];
int n;

int solve(vector <int> a) {
	if (wxw.count(a)) return wxw[a];
	int n = (int)a.size();
	vector <int> f(n + 1, 0);
	f[0] = 1;
	for (int l = 0; l < n; l++) {
		for (int r = l; r < n; r++) {
			int len = r - l + 1, nowl = l, nowr = r;
			vector <int> v(len, 0);
			for (int i = l; i <= r; i++) v[i - l] = a[i];
			while (nowr + len < n) {
				nowl += len; nowr += len;
				for (int i = nowl; i <= nowr; i++) v[i - nowl] = min(v[i - nowl], a[i]);
				int multi = solve(v);
				f[nowr + 1] = add(f[nowr + 1], mul(f[l], multi));
			}
		}
		f[l + 1] = add(f[l + 1], mul(f[l], a[l] + 1));
	}
	return wxw[a] = f[n];
}

int main() {
	scanf("%s", c + 1); n = strlen(c + 1);
	for (int i = 1; i <= n; i++) a.push_back(c[i] - 48);
	print(solve(a), '\n');
	return 0;
}

Measured memory_bytes: 5244
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	vector<vector<int>> dp(3010, vector<int>(3010,0));
	dp[0][0] = 0;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < T.size(); j++) {
			if (S[i] == T[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	string res = " ";
	int i = S.size();
	int j = T.size();
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i][j - 1]) {
			j--;
		}
		else if (dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else {
			res = S[i - 1] + res;
			i--;
			j--;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
 
int main(){
  double a,b,c,s,l,h;
  cin >> a >> b >> c;
  s = (a*b*sin(M_PI*c/180.0))/2.0;
  l = a + b + sqrt(a*a+b*b-2.0*a*b*cos(M_PI*c/180.0));
  h = b*sin(M_PI*c/180.0);
  printf("%.8lf\n%.8lf\n%.8lf\n",s,l,h);
}


Measured memory_bytes: 3484
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

//解説
//bの順でソートする
int N,M;
int a[100005],b[100005];

vector< pair<int,int>  > ab;
//BIT(Fenwick) TREE(1-indexed)
struct BITtree{
    int N;
    int *bit;
    BITtree(int n){
        N=n;
        bit=new int[N+1];
        rep(i,N+1){
            bit[i]=0;
        }
    }
    int sum(int i){//a_0,a_1,...a_iを計算する
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i & -i;
        }
        return s;
    }
    void add(int i,int x){//a_i+=xとする
        while(i<=N){
            bit[i]+=x;
            i+=i& -i;
        }
    }
    void free(){
        delete[] bit;
    }
};
signed main(){
    scanf("%lld %lld",&N,&M);
    BITtree ftree(N-1);
    rep(i,M){
        scanf("%lld %lld",&a[i],&b[i]);
        ab.pb(mp(b[i],a[i]));
    }
    sort(ab.begin(),ab.end());
    int ans=0;
    rep(i,ab.size()){
        int b=ab[i].first;
        int a=ab[i].second;
        //すでに切られているかどうか調べる
        int ifcut=ftree.sum(b-1)-ftree.sum(a-1);
        if(ifcut>0){//すでに切られているので何もしない
            continue;
        }else{//切る
            ftree.add(b-1,1);
            ans+=1;
        }
    }
    ftree.free();
    printf("%lld\n",ans);
}

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

#define int long long int
#define vi vector<int>
#define vvi vector<vi>

signed main() {
    int n, m;
    cin >> n >> m;
    vvi a;
    for(int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        a.push_back({ x, y, z });
    }
    int ans = LLONG_MIN;
    for(int i = 0; i < 8; i++) {
        vi v(n, 0);
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < 3; k++) {
                if(i & (1 << k)) {
                    v[j] += a[j][k];
                }
                else {
                    v[j] -= a[j][k];
                }
            }
        }
        sort(v.begin(), v.end(), greater<int>());
        int curr = 0;
        for(int j = 0; j < m; j++) {
            curr += v[j];
        }
        ans = max(ans, curr);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    int A;
    double sum = 0.0;
    cin >> N;
    
    for(int i = 0; i < N; i++){
        cin >> A;
        sum += 1.0/A;
    }
    
    cout << 1.0/sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
//ll size = 50000000;

int main(){
 //vector<ll> a(size,0);
 //for(ll i=1;i<size;i++) a[i] = i;
 //for(ll i=1;i<size;i++) a[i] += a[i-1];

 while(1){
  ll n;
  cin>>n;
  if(n==0)break;
  
  ll b=n,c=1;
  for(ll i=1; i*(i-1)/2 < n ; i++ ){
   ll rest = n - i*(i-1)/2;
   if( rest%i == 0) b = rest/i ,c = i;
  }
  cout<<b<<' '<<c<<endl;

 }
    return 0;
}



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

using namespace std;

typedef long long ll;

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

	int a, b;
	cin >> a >> b;

	int ans = 0;
	for(int i = 0; i < 2; i++){
		if(a > b){
			ans += a;
			a--;
		}else{
			ans += b;
			b--;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)


int costmin(int n,int h[]){
	int *dp=new int[n+1]{INT_MAX};
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
 	for(int i=2;i<n;i++){
    	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
   return dp[n-1];
}


int main(){
	fastio();
	int n;cin>>n;
	int a[n];
	for(int&x:a) cin>>x;
	int ans=costmin(n,a);
	cout<<ans<<endl;







    return 0;
	
}

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

struct unionFind {
  vector<int> d;  // 根： 木のサイズ x -1, それ以外： 親のID
  unionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    // root化しておく
    x = find(x);
    y = find(y);
    if (x == y) return false;

    // x を y に unite
    // d[x] のほうが多きい（=サイズが小さい）場合はswap
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m), y(m);
  rep(i, m) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }

  int ans = 0;
  rep(i, m) {
    unionFind uf = unionFind(n);
    rep(j, m) if (i != j) uf.unite(x[j], y[j]);
    if (!uf.same(x[i], y[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	std::string s, t;

	std::cin >> s >> t;
	
	unsigned min = t.size();
	unsigned pos = 0;
	for(unsigned int i = 0; i <= s.size() - t.size() ; ++i)
	{	unsigned diff = 0;
		for(unsigned j = 0 ; j < t.size(); ++j)
		{	
			if(s[i+j] != t[j])
			{
				++diff;
			}
		}
		if(diff < min)
		{
			min = diff;
			pos = i;
		}	
	}
	
	std::cout << min << std::endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main() {
  int n, x, i=1;
  scanf("%d", &n);
  while(++i <= n) {
    if(i % 3 == 0) printf(" %d", i);
    else {
      if(i % 10 == 3) printf(" %d", i);
      else {
        x = i;
        while(x) {
          if(x % 10 != 3) x /= 10;
          else {
            printf(" %d", i);
            break;
          }
        }
      }
    }
  }
  printf("\n");
  return 0;
}


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

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

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

  int n;
  cin >> n;

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

    auto mp = prime_factor(i);

    int t = 1;
    for (auto m : mp)
      t *= m.second + 1;

    if (t == 8)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  
  int x,i,t;
  
  scanf("%d", &x);
  
  i = (x / 500);
  
  t = ((x-(500*i)) / 5);
  
  printf("%d", ((1000*i)+(5*t)));
  
  return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#define N 100000
#define Q 500
int linearSearch(int*, int);
int n;
int main()
{
  int q;
  int s[N],t[Q];
  int i;
  int c=0,cnt=0;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&s[i]);
  }
  
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&t[i]);
  }

  for(i=0; i<q; i++){
    c = linearSearch(s,t[i]);
    if(c!=1) cnt++;
  }

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

  return 0;
  
}

int linearSearch(int *x,int key)
{
  int i;
  for(i=0; i<n; i++){
    if(x[i]==key) return 0;
  }
  
  return 1;
}

Measured memory_bytes: 648
#include<stdio.h>

int main(){
  int a, b;

  scanf("%d%d", &a, &b);

  if(a%3==0 || b%3==0 || (a+b)%3==0){
    printf("Possible\n");
  }else{
    printf("Impossible\n");
  }
  
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int flag=0;
  if(S.at(0)=='A') flag++;
  int ctest=0;
  for(int i=2; i<S.size()-1; i++){
    if(S.at(i)=='C') ctest++;
  }
  if(ctest==1) flag++;
  int constest=0;
  for(int i=1; i<S.size(); i++){
    if(S.at(i)>='a' && S.at(i)<='z') constest++;
  }
  if(constest==S.size()-2) flag++;
  if(flag==3) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int M[MAX][MAX], color[MAX], d[MAX], p[MAX];

int n;

void dijkstra(int s){
    int u = s;
    for(int u = 0; u < n; u++){
        color[u] = WHITE;
        d[u] = INFTY;
    }
    d[s] = 0;
    p[s] = -1;

    while(1){
        int mincost = INFTY;
        for(int i = 0; i < n; i++){
            if( color[i] != BLACK && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }
        if(mincost == INFTY) break;

        color[u] = BLACK;

        for(int v = 0; v < n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[u] + M[u][v] < d[v]){
                    d[v] = d[u] + M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
}
int main(){
    cin >> n;
    int u, k, v, c;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = INFTY;
        }
    }

    for(int i = 0; i < n; i++){
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra(0);

    for(int i = 0; i < n; i++){
        cout << i << " " << d[i] << endl;
    }

    return 0;
}


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

int main(){
  int N;
  long long ans=0;
  cin >> N;
  vector<int> a(N+1),b(N);
  for(int i=0;i<N+1;i++){
    cin >> a.at(i);
  }
   for(int i=0;i<N;i++){
    cin >> b.at(i);
  }
  for(int i=0;i<N;i++){
    if(a.at(i)>=b.at(i)){
      ans += b.at(i);
    }
    else{
      ans += a.at(i);
      ans += min(b.at(i)-a.at(i),a.at(i+1));
      a.at(i+1)=max(a.at(i+1)-b.at(i)+a.at(i),0); 
    }
  }
  cout << ans;
}
  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a, a + n);
	int Tmp = a[n / 2];
	int Ans = 0;
	for (int i = 0; i < n; i++) {
		Ans += abs(a[i] - Tmp);
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long

int main(void){
    char s[10];
    int i;

    REP(i,10){
        scanf("%c",&s[i]);
    }
    
    s[3]='8';

    REP(i,10){
        printf("%c",s[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    int c[3][3];
    int cc[3][3];
    rep(i,3)rep(j,3){
        cin >> c[i][j];
        cc[i][j] = c[i][j];
        
    }
    bool flag = true;
    int a = c[0][0]-c[0][1];
    rep(i,2){
        if(c[i+1][0]-c[i+1][1]!=a)flag = false;
    }
    a = c[0][0]-c[0][2];
    rep(i,2){
        if(c[i+1][0]-c[i+1][2]!=a)flag = false;
    }
    rep(i,3)rep(j,3)c[i][j] = cc[j][i];
    a = c[0][0]-c[0][1];
    rep(i,2){
        if(c[i+1][0]-c[i+1][1]!=a)flag = false;
    }
    a = c[0][0]-c[0][2];
    rep(i,2){
        if(c[i+1][0]-c[i+1][2]!=a)flag = false;
    }
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    set<char> s;
    iter(c, S) s.insert(c);
    rep(i, 26) {
        if(s.find('a' + i) == s.end()) {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 3780
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
	int n;cin>>n;
	int ans=0;
	rep(i,1,n+1)
	{
		if(i%3 and i%5)ans+=i;
	}
	cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
while(t--)
{
	solve();
}
}

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

ll GCD(ll a, ll b){
  if( b == 0 ){ return a;}
  else{ return GCD(b,a%b);}
}


int main(){ 
  ll T; cin >> T;
  
  while(T--){ 
    
    ll a,b,c,d; cin >> a >> b >> c >> d;
    
    if( b > d || a < b ){ cout << "No" << endl; continue;}
    else if( b-1 <= c ){ cout << "Yes" << endl; continue;}
    
    ll g = GCD(b,d);
    
    ll k;
    
    if( c < a ){ 
      ll l;
      if( (a-c) % g == 0 ){ l = (a-c)/g; l--;}
      else{ l = (a-c)/g;}
      
      k = -l;
    }
    else if( c == a ){ k = 1;}
    else{
     if( (c-a) % g == 0 ){ k = (c-a)/g; k++; }
     else{ k = (c-a+g-1)/g;}
    }
    
    ll test = a+g*k;
    
    if( test < b ){ cout << "No" << endl;}
    else{ cout << "Yes" << endl;}
    
  }
  
  return 0;
}

Measured memory_bytes: 256
from copy import deepcopy

V,E = list(map(int,input().split()))

#M[u][v]:uからvへの重みを保存した隣接行列
INF = 2**36 - 1

M=[[INF]*V for x in range (V)]
for n in range(E):
    input_temp = list(map(int,input().split()))
    M[input_temp[0]][input_temp[1]]=input_temp[2]
    
for v in range(V):
    M[v][v]=0    

def warshallFloyd(M):
    ret = deepcopy(M)
    for k in range(V):
        for i in range(V):
            if ret[i][k] == INF:
                continue
            for j in range(V):
                if ret[k][j] == INF:
                    continue
                ret[i][j] = min(ret[i][j], ret[i][k] + ret[k][j])
    return ret 

def check_negative_cycle(W):
    negative_cycle=False
    for v in range(V):
        if W[v][v] < 0:
            negative_cycle=True
            break
    return negative_cycle

ans=warshallFloyd(M)
negative_cycle=check_negative_cycle(ans)

if negative_cycle:
    print('NEGATIVE CYCLE')
else:
    for i in range(V):
        for j in range(V):
            print(ans[i][j] if ans[i][j] != INF else "INF", end='')
            if j == V - 1:
                print()
            else:
                print(' ', end='')


Measured memory_bytes: 7684
#include <bits/stdc++.h>
using namespace std;
int c[100001],n;
int lowbit(int x)
{
	return x&(-x);
}
int sum(int x)
{
	int s=0;
	while(x>0)
	{
		s+=c[x];
		x-=lowbit(x);
	}
	return s;
}
void increase(int x,int v)
{
	while(x<=n)
	{
		c[x]+=v;
		x+=lowbit(x);
	}
	return;
}
int main()
{
	int i,m,x,y,ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		increase(x,1);
		increase(y+1,-1);
	}
	for(i=1;i<=n;i++)
		if(sum(i)==m)
			ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const int mxN=1e9;
const ll mod = 1e9+7;

ll pow(ll a,ll b){
    ll r =1;
    while(b){
        if(b%2!=0) r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }

    return r;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;

    vector<ll> v(n);

    for(int i=0;i<n;i++) cin>>v[i];

    vector<ll> pref(n+1);
    pref[0]=0;

    for(int i=1;i<=n;i++){
        pref[i]= pref[i-1]+v[i-1];
    }
    
    ll dp[n][n];

    for(int i=0;i<n;i++){
        for(int j=0;j+i<n;j++){
            if(i+j==j)dp[j][j+i]=0;
            else{
                dp[j][i+j]=1e18L+5;
                for(int k =j;k<=j+i-1;k++){
                    dp[j][i+j] = min(dp[j][i+j],dp[j][k]+dp[k+1][i+j]+(pref[i+j+1]-pref[j]));
                }
            }
        }
    }

    cout<<dp[0][n-1];
}

Measured memory_bytes: 4856
let cnt = ref 0
let (g : int list ref) = ref []

let insertion_sort (a : int array) n g =
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j+g) <- v
    else (a.(j+g) <- a.(j); incr cnt; insert (j - g) v)
  and doit i =
    if i < n then (insert (i - g) a.(i); doit (i + 1))
  in doit g

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc)
  in doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  g := generate_g n;
  let rec doit = function
    | [] -> ()
    | hd :: tl -> (insertion_sort a n hd; doit tl)
  in doit !g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) !g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int ans= 0;
    int k,s;cin>>k>>s;
    for(int x = 0;x<=k;x++) {
        for(int y = x+1;y<=k;y++){
            if(s-x-y>y && k >= s-x-y) ans += 6;
        }
    }
    for(int xy = 0;xy<=k;xy++) {
        for(int z = 0;z<=k;z++) {
            if(xy == z) {
                if(xy*3 == s) ans++;
            }else {
                if(xy*2+z == s) ans+= 3;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256