akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

#define INF 1e+10
#define MAX_V 10000

struct edge {
    long long to;
    long long cost;
};

// <最短距離, 頂点の番号>
using P = pair<long long, long long>;

long long V;
vector<edge> G[MAX_V];
long long d[MAX_V];

void prim(long long s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        long long v = p.second;
        if (d[v] < p.first) continue;
        d[v] = -d[v];
        for (long long i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > e.cost) {
                d[e.to] = e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V;
    long long E;
    cin >> E;
    for (long long i=0; i<E; ++i) {
        long long a, b, c;
        cin >> a >> b >> c;
        edge e = {b, c};
        G[a].push_back(e);
        edge e2 = {a, c};
        G[b].push_back(e2);
    }
    prim(0);
    long long sum = 0;
    for(long long i=0; i<V; i++){
        sum += -d[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 9024
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(scanf("%d %d",&H,&W)){
    if(H==0&&W==0)break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	if(i==0||i==H-1||j==0||j==W-1)printf("#");
	else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
int main()
{
  int n,i,j,c=0;
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      if(4*i+7*j==n)
        c++;
    }
  }
  if(c!=0)
    printf("Yes\n");
  else
    printf("No\n");

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    int g = __gcd(a, b);
    rep(i, n-2){
        int tmp;
        cin >> tmp;
        g = __gcd(tmp, g);
    }
    cout << g << endl;

}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

int keta(ll x){
    int ans = 0;
    while(x>0){
        x/=10;
        ans++;
    }
    return ans;
}
int saidai(ll x){
    while(x>=10){
        x/=10;
    }
    return x;
}
bool nine(ll x){
    while(x>=10){
        int y=x%10;
        if(y!=9)return false;
        x/=10;
    }
    return true;
}
int main(){
    ll n;
    cin >> n;
    if(nine(n)) cout << (keta(n)-1)*9+saidai(n) << endl;
    else cout << (keta(n)-1)*9+saidai(n)-1 << endl;
    return 0;
}

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

typedef pair<int, int> PII;
typedef vector<PII> VII;
int main() {
  
  int N;
  bool blank = 0;
  cin >> N;
  rep(_, N) {
    if(blank) cout << endl;
    blank = 1;
    int arr[9][9] = {{}};
    char output[9][20] = {{}};
    VII star;
    rep(i, 9) {
      int used[10] = {};
      rep(j, 9) {
	cin >> arr[i][j];
	used[arr[i][j]] ++;
	output[i][2*j]   = ' ';
	output[i][2*j+1] = (char)('0' + arr[i][j]);
      }
    }
    
    rep(i, 9) {
      int used[10] = {};
      rep(j, 9) used[arr[i][j]] ++;
      rep(j, 9) if(used[arr[i][j]] > 1) output[i][2*j] = '*';
    }
    
    rep(j, 9) {
      int used[10] = {};
      rep(i, 9) used[arr[i][j]] ++;
      rep(i, 9) if(used[arr[i][j]] > 1) output[i][2*j] = '*';
    }
    
    rep(i, 3) {
      rep(j, 3) {
	int used[10] = {};
	rep(k, 3) rep(l, 3) used[arr[i*3+k][j*3+l]] ++;
	rep(k, 3) rep(l, 3) if(used[arr[i*3+k][j*3+l]] > 1) output[(i*3+k)][2*(j*3+l)] = '*';
      }
    }
    
    rep(i, 9) cout << output[i] << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1156
N, M, X = map(int, input().split())
Book = [list(map(int, input().split())) for _ in range(N)]
List = [[0 for _ in range(M+1)] for _ in range(2**N)]
Min = float("inf")
for i in range(2**N):
  for j in range(N):
    if ((i >> j) & 1):
      for k in range(M+1):
        List[i][k] += Book[j][k]
      if Min > List[i][0] and min(List[i][1:]) >= X:
        Min = List[i][0]
if Min == float("inf"):
  print(-1)
else:
  print(Min)

Measured memory_bytes: 70040
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
#define mp make_pair
deque<pair<int,int> > q;
bool vis[100005];
int k,ans=0; 
int main()
{
	cin>>k;
	q.push_front(mp(1,1));
	while(!q.empty()){
		pair<int,int> x=q.front();
		q.pop_front();
		if(x.first==0){
			cout<<ans+x.second;
			return 0;
		}
		if(vis[x.first]){
			continue;
		}
		vis[x.first]=1;
		q.push_back(mp((x.first+1)%k,x.second+1));
		q.push_front(mp((x.first*10%k),x.second));
	}
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string t;
  cin >> t;
  int a=0;
  int b=0;
  if (t[0] == '0' && t[1] != '0'){
    a=1;
  }
  if (t[0] == '1' && (t[1] == '1'|| t[1] == '2')){
    a=1;
  }
  if (t[2] == '0' && t[3] != '0'){
    b=1;
  }
  if (t[2] == '1' && (t[3] == '0' || t[3] == '1'|| t[3] == '2')){
    b=1;
  }
  
  if (a==0 && b==0){
    cout << "NA" << endl;
  }
  if (a==0 && b==1){
    cout << "YYMM" << endl;
  }
  if (a==1 && b==0){
    cout << "MMYY" << endl;
  }
  if (a==1 && b==1){
    cout << "AMBIGUOUS" << endl;
  }
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {
	int n;
	cin >> n;
	VI a(n);
	REP(i, n)cin >> a[i];
	int ans = 0;
	sort(ALL(a));
	REP(i, n) {
		FOR(j, i + 1, n) {
			FOR(k, j + 1, n) {
				if (a[i] + a[j] > a[k])ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

const int inf=1e9+10;

int a,b;
string s1,s2;

int main(){
	cin>>a>>b;
	for(int i=0;i<a;i++) s1+=char(b+'0');
	for(int i=0;i<b;i++) s2+=char(a+'0');
	if(s1>s2) swap(s1,s2);
	cout<<s1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 1000000007;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}


void solve()
{
	ll x[6],ans=0;
	cin>>x[1]>>x[2]>>x[3]>>x[4]>>x[5];	
	
	for(ll i=1;i<=5;i++)
	{
		if(i!=x[i] && x[i]==0)
		{
		ans = i;
		break;	
		}
		
	}
	
	
	// cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    cout<<ans<<endl;
return ;
}


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


Measured memory_bytes: 3160
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;

struct military{
	int ptn;
	vector<int> c;

	military(): ptn(0){}
	bool operator< (const military &m) const{
		if(ptn != m.ptn) return ptn < m.ptn;
		return next() > m.next();
	}
	
	int next() const{
		return ptn - c.back();
	}
};

bool solve(int n, int d){
	vector<military> mils(n);
	for(int i = 0; i < n; ++i){
		int m;
		scanf("%d", &m);
		mils[i].c.resize(m + 1);
		for(int j = 1; j <= m; ++j){
			scanf("%d", &mils[i].c[j]);
			mils[i].ptn += mils[i].c[j];
		}
	}

	while(1){
		int minptn = min_element(mils.begin(), mils.end())->ptn;
		int k = max_element(mils.begin(), mils.end()) - mils.begin();
		if(mils[k].ptn - minptn > d) return false;
		if(mils[k].ptn == 0) return true;

		for(int i = 0; i < n; ++i){
			if(i == k) continue;
			while(mils[i].c.size() > 1){
				if(mils[i].next() < mils[k].ptn - d)
					break;
				mils[i].ptn -= mils[i].c.back();
				mils[i].c.pop_back();
			}
		}

		mils[k].ptn -= mils[k].c.back();
		mils[k].c.pop_back();
	}
}

int main(){
	int n, d, m;
	while(scanf("%d%d", &n, &d), n){
		puts(solve(n, d) ? "Yes" : "No");
	}
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef double ld;
#define X first
#define Y second
#define mk make_pair
#define pb push_back
#define Rep(i, n) for(int i = 0; i < int(n); i ++)
#define Rep1(i, n) for(int i = 1; i <= int(n); i ++)
#define all(x) (x).begin(), (x).end()
const int MOD = (int) 1e9 + 7;
const ll base =  31;
void MAIN();
int main(){
    //freopen("input.txt", "r", stdin);
    ios:: sync_with_stdio(false); cin.tie(0);
    MAIN();
    return 0;
}
////////////////////////////////////////////////////////////////////////

const int N = 3004;

int n, t, s, f[N];
int a, b;

void MAIN(){
    cin >> n >> t >> s;
    int ans = 0;
    for(int i = 1; i <= n; i ++){
        cin >> a >> b;
        for(int j = t; j >= b; j --){
            if(!(j > s && j - b < s)) f[j] = max(f[j], f[j-b] + a);
            ans = max(ans, f[j]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1208
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll h, w;

ll dif(ll a, ll b, ll c) {
    return max(max(a, b), c) - min(min(a, b), c);
}

ll solve() {
    if (h % 3 == 0 || w % 3 == 0) return 0;
    ll res = min(w, h);
    for (int i = 1; i < w; i++) {
        res = min(res, dif(h * i, (w-i)*(h/2), (w-i)*(h/2+(h%2==1))));
    }
    for (int i = 1; i < h; i++) {
        res = min(res, dif(w * i, (h-i)*(w/2), (h-i)*(w/2+(w%2==1))));
    }
    return res;
}

void input() {
    cin >> h >> w;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define REPR(i,n,m) for(int i=n;i>m;i--)
#define ALL(v) v.begin(),v.end()
#define elif else if
using ll=long long;

int gcd(int x,int y){
    int a;
    while(y!=0){
        a=x%y;
        x=y;
        y=a;
    }
    return x;
}

int lcm(int a,int b){
    return a*b/gcd(a,b);
}

/*----------template----------*/

int main(){
    ll a,b,k;
    cin>>a>>b>>k;

    if(a>=k) cout<<a-k<<' '<<b<<endl;

    elif(a+b>=k) cout<<0<<' '<<b-k+a<<endl;

    else cout<<"0 0"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	ll res = numeric_limits<ll>::max();
	for(int i = 0; i <= max(x, y) * 2; i += 2) {
		res = min(res, max((x - i / 2), 0LL) * a + max((y - i / 2), 0LL) * b + i * c);
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        l: u64,
        r: u64
    }

    let result = xor(l, r);
    println!("{}", result);
}

fn xor(l: u64, r: u64) -> u64 {
    if l > r {
        xor(r, l)
    } else if l == 0 {
        match r % 4 {
            0 => r,
            1 => 1,
            2 => r + 1,
            3 => 0,
            _ => 9999
        }
    } else {
        xor(0, l - 1) ^ xor(0, r)
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int64_t MOD = 1e9+7;
int main(){
  int H, W, K;
  cin >> H >> W >> K;
  int64_t dp[H+1][W];
  for(int i=0; i<H+1; i++){
    for(int j=0; j<W; j++){
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for(int i=0; i<H; i++){
    for(int bit = 0; bit < (1 << W-1); bit++){
      map<int,bool> mp;
      bool flag = true;
      for(int n=0; n<W-1; n++){
        if(bit & (1 << n)){
          if(mp.count(n-1)){
            flag = false;
          }
          mp[n] = true;
        }
      }
      if(flag){
        /*for(auto itr = mp.begin(); itr != mp.end(); itr++){
          cout << itr->first << " ";
        }
        cout << endl;*/
        for(int j=0; j<W; j++){
          if(mp.count(j)){
            dp[i+1][j+1] += dp[i][j]; 
            dp[i+1][j+1] %= MOD;
          }
          else if(mp.count(j-1)){
            dp[i+1][j-1] += dp[i][j];
            dp[i+1][j-1] %= MOD;
          }
          else{
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
          }
        }
      }
    }
  }
  /*for(int i=0; i<H+1; i++){
    for(int j=0; j<W; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 256
import math
(_,), a  = [list(map(int, s.split())) for s in open(0)]
 
def fast_factorize(num):
    min_factor_list = list(range(num + 1))
    for i in range(int(math.sqrt(num) + 1), 1, -1):
        for j in range(i, num+1, i):
            min_factor_list[j] = i
    return min_factor_list
 
min_factor_list = fast_factorize(max(a))
 
prime_factor_sets = []
for x in a:
    prime_factor_set = set()
    while min_factor_list[x] != 1:
        prime_factor_set.add(min_factor_list[x])
        x //= min_factor_list[x]
    prime_factor_sets.append(prime_factor_set)

g = prime_factor_sets[0].copy()
l = set()
s = 0
for x in prime_factor_sets:
    g &= x
    l |= x
    s += len(x)

if len(g) != 0:
    ans = 'not coprime'
elif len(l) != s:
    ans = 'setwise coprime'
else:
    ans = 'pairwise coprime'
print(ans)

Measured memory_bytes: 400248
import collections
N=int(input())
A=collections.deque()
for i in range(N):
    c=input()
    if c[0]=='i':
        A.appendleft(int(c.split()[1]))
    elif c[6]==' ':
        if int(c.split()[1]) in A:
            A.remove(int(c.split()[1]))
    elif c[6]=='F':
        A.popleft()
    elif c[6]=='L':
        A.pop()
print(*A)


Measured memory_bytes: 45940
n = int(input())
h = list(map(int,input().split()))
dp = [0] * n

dp[1] = abs(h[0] - h[1])

for i in range(2,n):
    p = abs(h[i] - h[i-2]) + dp[i-2]
    q = abs(h[i] - h[i-1]) + dp[i-1]
    if p <= q:
        dp[i] = p
    else:
        dp[i] = q

print(dp[-1])

Measured memory_bytes: 20376
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

void solve(ll N){
    ll sum = 0;
    rep2(i, 1, N) if ((i % 3 != 0) && (i % 5 != 0)) sum += i;
    cout << sum << "\n";
}

int main() {
    ll N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define SQ 320
#define N 8388607
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,l,timer;
ll a[305][305], d[305][305];
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n;
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
        {
            cin >> a[i][j];
            d[i][j] = a[i][j];
            if (i == j && a[i][j] != 0)
            {
                cout << -1 << endl;
                return 0;
            }
        }
    for (i = 0; i < n; i++)
        for (j = i+1; j < n; j++)
        {
            if (a[i][j] != a[j][i])
            {
                cout << -1 << endl;
                return 0;
            }
        }
    for (int k=0; k<n; ++k)
        for (int i=0; i<n; ++i)
            for (int j=0; j<n; ++j)
                d[i][j] = min (d[i][j], d[i][k] + d[k][j]);
    long long ans = 0;
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            if (a[i][j] != d[i][j])
            {
                cout << -1 << endl;
                return 0;
            } else
                ans += d[i][j];
    for (int i=0; i<n; ++i)
        for (int j=0; j<n; ++j)
            for (k = 0; k < n; k++)
                if (d[i][j] == d[i][k] + d[k][j] && i != k && j != k)
                {
                    ans -= d[i][j];
                    break;
                }
    cout << ans/2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N) {
		cout<<(N+1)/2<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    vector<int> a(n+1,0);
    vector<int> b(n,0);
    for(int i = 0;i < n+1; i++){
        cin>>a[i];
    }
    for(int i = 0;i < n; i++){
        cin>>b[i];
    }
    ll sum=0;
    int copy;
    for(int i = 0;i < n; i++){
        if(b[i]>a[i]){
            //cout<<"a"<<endl;
            sum+=a[i];
            copy=a[i];
            a[i]=0;
            b[i]-=copy;
            if(b[i]>0){
                if(b[i]>a[i+1]){
                    sum+=a[i+1];
                    copy=a[i+1];
                    a[i+1]=0;
                    //b[i]-=copy;
                }
                else if(b[i]<=a[i+1]){
                    sum+=b[i];
                    a[i+1]-=b[i];
                    //b[i]=0;
                }
            }
            /*
            rep(i,n+1) cout<<a[i]<<" ";
            cout<<endl;
            rep(i,n) cout<<b[i]<<" ";
            cout<<endl;
            cout<<"sum"<<sum<<endl;
            */

        }
        else if(b[i]<=a[i]){
            //cout<<"b"<<endl;
            sum+=b[i];
            a[i]-=b[i];
            b[i]=0;
            /*
            rep(i,n+1) cout<<a[i]<<" ";
            cout<<endl;
            rep(i,n) cout<<b[i]<<" ";
            cout<<endl;
            cout<<sum<<endl;
            */
        }
        //cout<<endl;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  ll ans = 0;
  for(int b = k + 1; b <= n; b++){
    ans += (n / b) * max(0, b - k)+ max(0, n + 1 - (n / b) * b - k);
    if(!k) ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# solution ver.連想配列（つまり辞書）
N = int(input())
num = [0 for i in range(N)]   

dict1 = {}    # キーは入力値、値はそのキーがあれば１なければ０（ない値は対応するキーがそもそもないから、すべての値は１）
for i in range(N):
    dict1[input()] = 1
    
list1 = list(dict1.values())
print(len(list1))

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	bool s[30] = { };
	REP(i, 28){
		int x;
		cin >> x;
		s[x-1] = true;
	}
	REP(i, 30) if(!s[i]) cout << i+1 << endl;
	return 0;
} 


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

bool is_prime(long long n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else if (n % 2 == 0) {
        return false;
    }
 
    for (long long i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    vector<int> s(100001, 0);
    set<int> p;
    p.insert(2);
    for (int i = 3; i <= 100000; i++) {
        s[i] = s[i - 1];
        if (is_prime(i)) {
            p.insert(i);
            if (p.count((i + 1) / 2) == 1) {
                s[i]++;
            }
        }
    }

    int q, l, r;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> l >> r;
        cout << s[r] - s[l - 1] << endl;
    }
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;
ll fact(ll n, ll p){
	ll ans = 1;
	for(ll i = 1; i <= n; i++){
		ans *= i;
		ans %= p;
	}
	return ans;
}
ll power(ll x, ll n, ll p){
	ll res = 1;
	if(n == 1) return x%p;
	if(n%2 == 1) res = x%p;

	ll temp = power(x,n/2,p);
	return res*((temp*temp)%p)%p;
}
ll inv(ll a, ll p){
	return power(a,p-2,p);
}
ll nCr(ll n, ll r, ll p){
	if(r > n) return 0;
	ll t1 = fact(n,p);
	ll t2 = inv(fact(r,p),p);
	ll t3 = inv(fact(n-r,p),p);

	return (((t1*t2)%p)*t3)%p;
}
vector<vector<ll> > multiply(vector<vector<ll> > &a, vector<vector<ll> > &b, ll p){
	int r1,c1,r2,c2;
	r1 = a.size(); c1 = a[0].size();
	r2 = b.size(); c2 = b[0].size();

	vector<vector<ll> > result(r1,vector<ll>(c2,0));

	if(c1 != r2) return result;

	for(int i = 0; i < r1; i++){
		for(int j = 0; j < c2; j++){
			for(int k = 0; k < c1; k++){
				result[i][j] += a[i][k]*b[k][j];
				result[i][j] %= p;
			}
		}
	}
	return result;
}
vector<vector<ll> > power(vector<vector<ll> >&a,ll n, ll p){
	int r = a.size();
	vector<vector<ll> > result(r,vector<ll>(r,0));
	for(int i = 0; i < r; i++) result[i][i] = 1;

	while(n > 0){
		if(n%2 == 1){
			result = multiply(result,a,p);
		}
		n /= 2;
		a = multiply(a,a,p);
	}
	return result;
}
// template ends here

void solve(){
	// code starts from here
	ll S, W;
	cin >> S >> W;
	if(W >= S) cout << "unsafe" << endl;
	else cout << "safe" << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int s = sc.nextInt();
			if(n==0 && s==0)break;
			
			if(s>45 || n>10 || n==0){
				System.out.println("0");
			}else if(n==10){
				if(s>35 && s<46){
					System.out.println("1");
				}else{
					System.out.println("0");
				}
			}else{
				int count = 0;
				
				for(int a=0;a<10;a++){
					if(n==1){
						if(s==a)count++;
					}else for(int b=a+1;b<10;b++){
						if(n==2){
							if(s==a+b)count++;
						}else for(int c=b+1;c<10;c++){
							if(n==3){
								if(s==a+b+c)count++;
							}else for(int d=c+1;d<10;d++){
								if(n==4){
									if(s==a+b+c+d)count++;
								}else for(int e=d+1;e<10;e++){
									if(n==5){
										if(s==a+b+c+d+e)count++;
									}else for(int f=e+1;f<10;f++){
										if(n==6){
											if(s==a+b+c+d+e+f)count++;
										}else for(int g=f+1;g<10;g++){
											if(n==7){
												if(s==a+b+c+d+e+f+g)count++;
											}else for(int h=g+1;h<10;h++){
												if(n==8){
													if(s==a+b+c+d+e+f+g+h)count++;
												}else for(int i=h+1;i<10;i++){
													if(n==9){
														if(s==a+b+c+d+e+f+g+h+i)count++;
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				System.out.println(count);
			}

		}
	}	
}

Measured memory_bytes: 17208
#include<stdio.h>

int main() {

	int a, b, c;

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

	if (a == b)
	{
		printf("a == b\n");
	}
	else if (a < b)
	{
		printf("a < b\n");
	}
	else
	{
		printf("a > b\n");
	}

	return 0;
}

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

int main()
{
        int a,b,x=0,y=0,z;
        cin>>a>>b;
        x=a+b;
        y=a-b;
        z=a*b;
        cout<<max(x,max(y,z))<<endl;
        return 0;
}


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

int N;
vector<int> A;

map<int, int> M;

int main() {
	cin >> N;
	A.resize( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
		M[A[i]]++;
	}
	sort( A.begin(), A.end(), greater<int>() );
	int ans = 0;
	int last = -1;
	for( int i = 0; i < N; i++ ) {
		if( A[i] == last ) {
			continue;
		}
		int a = A[i];
		last = a;
		int bi = 1 << (int)ceil( log2( (double)(a + 1) ) );
		int b = bi - a;
		if( b <= 0 ) {
			continue;
		}
		if( a == b ) {
			ans += M[a] / 2;
			M[a] = 0;
		}
		else {
			int c = min( M[a], M[b] );
			M[a] -= c;
			M[b] -= c;
			ans += c;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 19968
n, a, b = map(int,input().split())

ans = 0
for x in range(n+1):
    x_1 = x%10
    x_2 = (x%100)//10 + x_1
    x_3 = (x%1000)//100 + x_2
    x_4 = (x%10000)//1000 + x_3
    x_5 = (x%100000)//10000 + x_4
    if a<=x_1 and x_1<=b and x<10:
       ans += x
    if a<=x_2 and x_2<=b and 10<=x and x<100:
       ans += x
    if a<=x_3 and x_3<=b and 100<=x and x<1000:
       ans += x
    if a<=x_4 and x_4<=b and 1000<=x and x<10000:
       ans += x
    if a<=x_5 and x_5<=b and 10000<=x and x<=100000:
       ans += x

print(ans)


Measured memory_bytes: 3064
#include <cstdio>

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

Measured memory_bytes: 1000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    cout << N * (N+1)/ 2 << endl;
}

Measured memory_bytes: 3628
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  long double rad = PI * 2 * (H / 12.0 + (M / 60.0) / 12.0 - (M / 60.0));

  long double ans = A * A + B * B - 2 * A * B * cos(rad);

  printf("%20.20Lf\n", sqrt(ans));
  return 0;
}


Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long


int s[10];
int n,m,q;
int a[50], b[50], c[50], d[50];


int solve(){
  // LOOP(i,n){
  //   cerr << s[i] << " ";
  // }
  // cerr << endl;
  int score = 0;
  LOOP(i,q){
    if( s[b[i]-1] - s[a[i]-1] == c[i]) score += d[i];
  }
  // cerr << score << endl;
  return score;
}

int f(int i){
  // cerr << ".";
  int score = 0;
  if(i==n) return solve();
  if(i==0){
    LOOP1(k,m+1){
      s[i] = k;
      score = max(score, f(i+1));
    }
  }
  else{
    FOR(k, s[i-1], m+1){
      s[i] = k;
      score = max(score, f(i+1));
    }
  }
  return score;
}


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int cut(int i){
  // if(i%8)
    return i%8;
  //return 8;
}

signed main(){
  cin >> n >> m >> q;
  LOOP(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  cout << f(0);
}


Measured memory_bytes: 3584
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll s,w ;
	cin >> s >> w ;
	cout << (w>=s?"unsafe":"safe") << endl ;
}


Measured memory_bytes: 3636
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn f(H: &[i32], k: &i32) -> i32 {
    match H.iter().min() {
        Some(v) => {
            let mut res = v - k;
            for h in H.split(|num| num == v) {
                res += f(h, v); 
            }
            res
        },
        None => 0,
    }
}

fn main() {
    input! {
        N: i32,
        H: [i32; N],
    }
    
    println!{"{}",f(&H, &0)};
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    map<int, ll> m;
    rep(i, n) m[a[i]]++;

    ll sum = 0;
    for (auto e : m) sum += e.second * (e.second - 1) / 2;

    rep(i, n) {
        int cnt = m[a[i]];
        ll ans = sum - (cnt - 1);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 12252
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
    long n;
    while(cin>>n)
          {
              long long s=1,i;
     for(i=1;i<=n;i++){
        s=(s*i)%1000000007;
     }
     cout<<s<<"\n";
          }
    return 0;

}



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

int main() {
    ll x, y;
    ll a, b;
    ll ans = 1e9 + 7;
    cin >> x >> y;
    
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            a = pow(-1, i) * x;
            b = pow(-1, j) * y;
            if (a <= b) {
                ans = min(ans, i+j+b-a);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)for(int k=0;k<=c;k++)ans+=(500*i+100*j+50*k==x);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;
const double PI = acos(-1);
const int N = 1e5+1;

int n, m, a, b, in[100001];
ll dis[100001];
vector<int> adj[100001];

void bfs(int src) {
    queue<int> q;
    q.push(src);
    while (!q.empty()) {
        int p = q.front();
        q.pop();
        for (int ch : adj[p]) {
            in[ch]--;
            if (dis[ch] < dis[p]+1) {
                dis[ch] = dis[p]+1;
            }
            if (!in[ch]) {
                q.push(ch);
            }
        }
    }
}
int main() {
    //freopen("lazy.in", "r", stdin);
    IOS
    cin >> n >> m;
    while (m-->0) {
        cin >> a >> b;
        a--;
        b--;
        adj[a].emplace_back(b);
        in[b]++;
    }
    for (int i = 0; i < n; ++i) {
        if (!in[i] && !dis[i]) {
            bfs(i);
        }
    }
    ll mx = 0;
    for (int i = 0; i < n; ++i)  {
        mx = max(mx, dis[i]);
    }
    cout << mx << endl;




    return 0;


}


Measured memory_bytes: 6912
import collections
S = input()
cnt = 0

mod = [0]
reverse_S = S[::-1]
for i in range(len(reverse_S)):
  now = int(reverse_S[i]) * pow(10,i,2019)
  mod.append((now + mod[i]) % 2019)


c = collections.Counter(mod)
hindo = c.values()
for i in hindo:
  if i != 1:
    cnt += i*(i-1)//2


print(cnt)

Measured memory_bytes: 16796
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




vector<ll> color;
vector<ll> used;
vector<vector<ll>> edge;


void dfs(ll where,ll dist,ll clr){
    if(used[where]==-1){
        color[where]=clr;
    }
    used[where]=dist;
    if(dist==0){return;}
    for(auto &I:edge[where]){
        if(used[I]>=dist-1){continue;}
        dfs(I,dist-1,clr);
    }
}


int main(){
    ll n,m;
    cin>>n>>m;
    color.resize(n,0);
    used.resize(n,-1);
    edge.resize(n);
    for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ll q;
    cin>>q;
    vector<pair<pll,ll>> V(q);
    for(int t=0;t<q;t++){
        cin>>V[t].F.F>>V[t].F.S>>V[t].S;
        V[t].F.F--;
    }
    reverse(V.begin(),V.end());
    for(int i=0;i<q;i++){
        if(used[V[i].F.F]>=V[i].F.S){continue;}
        dfs(V[i].F.F,V[i].F.S,V[i].S);
    }
    for(int i=0;i<n;i++){
        cout<<color[i]<<endl;
    }
    
    
    
    
    
    
    
    return 0;
}


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int d,t,s;
    cin>>d>>t>>s;
    int ans=0;
    if(t*s>=d)
        cout << "Yes\n";
    else
        cout << "No\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3648
def main():
    S = input()
    cnt = 0
    ans = len(S)
    for s in S:
        if s == 'S':
            cnt += 1
        elif s == 'T':
            if cnt:
                cnt -= 1
                ans -= 2
        else:
            cnt = 0
    
    print(ans)

if __name__ == '__main__':
    main()

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

int main()
{
	using ll = long long;
	string s;
	cin >> s;
	ll ans = 0;
	
	for(int bit = 0; bit < (1<<(s.size()-1)); bit++) {
		ll temp = s[0] - '0';
		for(int i = 0; i < int(s.size()-1); i++) {
			if(bit & (1 << i)) {
				ans += temp;
				temp = 0;
			}
			temp = temp*10 + (s[i+1] - '0');
		}
		ans += temp;
	}
	cout << ans;
}


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

int main(){
  ll h,w;
  int n;
  cin>>h>>w>>n;
  ll ans[10];
  ans[0]=(h-2)*(w-2);
  rep(i,1,10) ans[i]=0;
  set<P> s;
  rep(i,0,n){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    rep(j,a-1,a+2){
      rep(k,b-1,b+2){
        if(0<j && j<h-1 && 0<k && k<w-1){
          int cnt=0;
          rep(l,j-1,j+2){
            rep(m,k-1,k+2){
              if(s.count(P(l,m))){
                cnt++;
              }
            }
          }
          ans[cnt]--;
          ans[cnt+1]++;
        }
      }
    }
    s.insert(P(a,b));

  }
  rep(i,0,10){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 4992
/*
*   Author : Ligyagami // Tushar Goyal
*/

#include <bits/stdc++.h>

using namespace std;

#define en '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define PI 3.14159265358979323846

void solve()
{
    double R;
    cin>>R;
    cout<<2*PI*R;
}

int main()
{
   fast;

   int T = 1;
   //cin>>T;

   while(T--)
    {
      solve();
    }

   return 0;

}



Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
const int maxn=1000+5;
const int maxW=5000+5;
const int inf=0x3f3f3f3f;
vector<int > ed[maxn];
void addedge(int from,int to)
{
    ed[from].push_back(to);ed[to].push_back(from);
}
int n;
int X[maxn],f[maxn][2],g[maxn][maxW];
void dfs(int v,int fa)
{
    f[v][0]=f[v][1]=inf;
    for(int i=0;i<(int)ed[v].size();i++){
        int u=ed[v][i];
        if(u!=fa) dfs(u,v);
    }
    for(int i=0;i<=1;i++){
        g[0][0]=0;
        int cnt=0;
        for(int j=1;j<=X[v];j++) g[0][j]=inf;
        for(int j=0;j<(int)ed[v].size();j++){
            int u=ed[v][j];
            if(u==fa) continue;
            cnt++;
            for(int w=0;w<=X[v];w++) g[cnt][w]=inf;
            for(int w=0;w<=X[v];w++){
                if(w+X[u]<=X[v]) g[cnt][w+X[u]]=min(g[cnt-1][w]+f[u][i^1],g[cnt][w+X[u]]);
                if(w+f[u][i^1]<=X[v]) g[cnt][w+f[u][i^1]]=min(g[cnt][w+f[u][i^1]],g[cnt-1][w]+X[u]);
            }
        }
        for(int w=0;w<=X[v];w++)
            f[v][i]=min(f[v][i],g[cnt][w]);
    }
    //printf("f[%d][0]=%d f[%d][1]=%d\n",v,f[v][0],v,f[v][1]);
}
int main()
{
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        int p;
        scanf("%d",&p);
        addedge(i,p);
    }
    for(int i=1;i<=n;i++) scanf("%d",&X[i]);
    dfs(1,-1);
    if(f[1][0]<inf || f[1][1]<inf) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 17408