akhauriyash/Code-Regression huggingface dataset:
// Problem : E - 1 or 2
// Contest : AtCoder - AtCoder Beginner Contest 126
// URL : https://atcoder.jp/contests/abc126/tasks/abc126_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//look at my code
//my code is amazing
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define vc vector
#define pb push_back
#define ar array
#define all(a) (a).begin(), (a).end()
#define ms(v,n,x) fill(v,v+n,x);
#define init(c,a) memset(c,a,sizeof(c))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
const int N=101010;
vll g[N];
ll vis[N];
void dfs(ll u){
	vis[u]=1;
	// trace(u);
	for(auto i:g[u]){
		if(!vis[i])
		dfs(i);
		
	}
	
}

int32_t main()
{
    
	fast
	ll n,m;
	cin>>n>>m;
	
	f(i,m){
		ll a,b,w;
		cin>>a>>b>>w;
		g[a].pb(b);
		g[b].pb(a);
				
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if(!vis[i]){
			// cout<<i<<" ";
			// trace(i);
			ans++;
			dfs(i);
		}
	}
	
	cout<<ans;
	
	

	



    

	return 0;
    
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long n,k;
    cin>>n>>k;
    long long a[n];
    long double b[n-k+1];
    b[0]=0;
    f(i,0,k){
        cin>>a[i];
        b[0]+=a[i];
    }
    f(i,k,n){
        cin>>a[i];
        b[i-k+1]=b[i-k]-a[i-k]+a[i];
    }
    sort(b,b+n-k+1);
    cout<<fixed<<setprecision(9)<<(b[n-k]+k)/2<<endl;
    return 0;
}


Measured memory_bytes: 8316
#include <iostream>
#include <map>

int main() {
  const unsigned long mod = 1000000000 + 7;
  unsigned long n;
  std::string s;
  std::cin >> n;
  std::cin >> s;

  std::map<char, unsigned long> alphabet_map;
  for (unsigned long i = 0; i < n; ++i) {
    alphabet_map[s[i]] += 1;
  }

  unsigned long sum = 1;
  for (const auto pair : alphabet_map) {
    sum *= ((pair.second + 1) % mod);
    sum %= mod;
  }

  std::cout << (sum - 1) % mod << std::endl;
  return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

inline bool ok(string& s) {
    li n = sz(s);
    if (s[0] == '0') {
        return false;
    }
    if (s[n - 1] == '1') {
        return false;
    }
    rep(i, (n - 1) / 2) {
        if (s[i] != s[n - 2 - i]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    li n = sz(s);
    if (!ok(s)) {
        puts("-1");
        return 0;
    }
    if (n == 2) {
        puts("1 2");
        return 0;
    }

    li head = 1;
    repp(i, 1, n) {
        cout << head << " " << i + 1 << endl;
        if (s[i - 1] == '1') {
            head = i + 1;
        }
    }

    return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int k,n;

  cin >> k >> n;

  vector<int> a(n);

  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  
  int dist,maxDist;
  maxDist = -1;
  for(ii=1;ii<n;ii++){
    dist = a[ii] - a[ii-1];
    if(dist > maxDist){
      maxDist = dist;
    }
                      
  }
  
  dist = k - a[n-1] + a[0];
  if(dist > maxDist){
    maxDist = dist;
  }

  cout << k - maxDist << endl;
  
  return 0;
}


Measured memory_bytes: 3932
N, M = map(int, input().split())
S = []
for _ in range(M):
    S.append(int(input()))
def fib(n):
  if n==-1:
    return 0
  elif n==0:
    return 1
  else:
    a, b = 0, 1
    for i in range(n):
        a, b = b, a + b
    return b
if len(S)==0:
  c=fib(N)
  print(c%1000000007)
else:
  if S[0]==1:
    c=1
  else:
    c=fib(S[0]-1)
  for i in range(M-1):
    c=c*fib(S[i+1]-S[i]-2)
  c=c*fib(N-S[M-1]-1)
  c=c%1000000007
  print(c)

Measured memory_bytes: 7084
package main

import (
	"fmt"
)

var N uint64
var K uint64

func main() {

	fmt.Scanf("%v", &N)
	fmt.Scanf("%v", &K)

	var total uint64

	// a,b,cが全てnKにある場合
	num := N / K
	total += num * num * num
	//fmt.Printf("total1=%v num=%v\n", total, num)

	// a,b,cが全て0.5K + nKにある場合
	if K % 2 == 0 {
		var n uint64
		for i := K/2; i <= N; i += K {
			n++
		}

		total += n * n * n
		//fmt.Printf("total2=%v n=%v\n", total, n)
	}

	fmt.Printf("%v\n", total)

}

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

int main() {
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    rep(i,t) cin >> a.at(i);

    sort(a.rbegin(), a.rend());
    int ans = k - 1 - 2 * (k - a.at(0));
    if (ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<pair<int, int>> ab(n);
    rep(i, n)
    {
        cin >> ab[i].first >> ab[i].second;
    }
    map<int, ll> mp;
    rep(i, n)
    {
        mp[ab[i].first] += ab[i].second;
    }
    ll cnt = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        cnt += itr->second;
        if (cnt >= k)
        {
            cout << itr->first << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 7980
#include<bits/stdc++.h>
using namespace std;
int main(){
	int ans=0;
	string c;
	cin>>c;
	for(int i=0;i<c.size();i++){
		if(ans==0&&c[i]=='C')ans++;
		if(ans==1&&c[i]=='F'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int n, count=0, max=0;
  string s;
  cin>>n;
  cin>>s;
  
  rep(i, n){
    if(s[i] =='I') count++ ;
  
    else count--;
    
    if(count>max) max = count;
  }
  
  cout<<max<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int a,b,c = 0;

  while( cin >> a >> b , a+b){
    int f = 1;

    if(c)cout << endl;

    for(int i = a ; i <= b ; i++){
      if(i%4 == 0){
	if(i%100 != 0 || i%400 == 0){
	  cout << i << endl;
	  f = 0;
	}
      }
    }
    if(f) cout << "NA" << endl;
    c = 1;
  }
  return 0;
}

Measured memory_bytes: 1160
n,m=map(int,input().split())
ans=0
for i in range(1,int(m**0.5)+1):
  if m%i>0:continue
  a=i
  b=m//i
  if a*n<=m:ans=max(ans,a)
  if b*n<=m:ans=max(ans,b)
print(ans)


Measured memory_bytes: 63908
import java.util.Scanner;

class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();

		int r[][] = new int[n][n];
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;

			r[a][b]++;
			r[b][a]++;
		}

		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j < n; j++) {
				sum += r[i][j];
			}
			System.out.println(sum);
		}

		sc.close();
	}
}


Measured memory_bytes: 22100
import numpy as np

N=int(input())

X=np.zeros(N)
Y=np.zeros(N)

for i in range(N):
  x, y = map(int, input().split())
  X[i]=x
  Y[i]=y

XX = np.tile(X, (N, 1))
YY = np.tile(Y, (N, 1))

dX = XX - XX.T
dY = YY - YY.T

norm=(dX**2 + dY**2)**0.5

#print(X)
#print(Y)
#print(dX)
#print(dY)
#print(norm)

ans=sum(norm.reshape(-1))/N
print(ans)


Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x,y;
    string s1,s2;
    cin>>s1>>s2;
    ll a,b;
//    a=0;
//    for(ll i=0;i<s1.size();i++)
//    {
//           if(s1[i]=='0'){a++;}
//           else break;
//    }
//    if(a>0) s1.erase(0, a);
//    b=0;
//    for(ll i=0;i<s2.size();i++)
//    {
//           if(s2[i]=='0'){b++;}
//           else break;
//    }
//    if(b>0) s2.erase(0, b);
   // cout<<s1<<endl;
    //cout<<s2<<endl;
    x=s1.size();
    y=s2.size();
    //cout<<x<<" "<<y<<endl;
    //if(s1==s2) {cout<<"EQUAL"<<endl;}
    if(x>y) cout<<"GREATER"<<endl;
    else if(x<y) cout<<"LESS"<<endl;
    else
    {

        if(s1>s2){cout<<"GREATER"<<endl;}
        else if(s1<s2){cout<<"LESS"<<endl;}
        else cout<<"EQUAL"<<endl;

    }
}



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

int main(){
  int N;
  cin >> N;
  
  vector<char> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }

  sort(vec.begin(),vec.end());
  
  bool ans=false;
 
  
  for(int i=0;i<N;i++){
  if(vec.at(i)=='Y'){
    ans=true;
  }
  }
  
    if(ans==true){
      cout << "Four" << endl;
    }
    else{
      cout << "Three" << endl;
    }
  
}
      
      


Measured memory_bytes: 256
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n, x, m;
    cin >> n >> x >> m;
    if (x == 0 || m == 1) {
        cout << 0 << endl;
        return 0;
    }
    map<ll, ll> work;
    ll a = x;
    work[a] = 1;
    ll off, loop;
    rrepp(i, 2, m) {
        a = a * a % m;
        auto it = work.find(a);
        if (it != work.end()) {
            off = it->second - 1;
            loop = i - it->second;
            break;
        }
        work[a] = i;
    }
    ll sum = 0;
    ll ii;
    for (a = x, ii = 0; ii < off; a = a * a % m, ++ii) {
        sum += a;
    }
    ll ls = 0;
    for (ii = 0; ii < loop; a = a * a % m, ++ii) {
        ls += a;
    }
    sum += ((n - off) / loop) * ls;
    for (ii = ((n - off) / loop) * loop + off; ii < n; a = a * a % m, ++ii) {
        sum += a;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 6224
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct edge{
    int to;
    lint cost;
};

struct node{
    int id;
    lint cost;

    bool operator<(const node& rhs) const {
        return cost > rhs.cost;
    }
};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n, m;
    cin >> n >> m;

    vector< vector<edge> > g(n);
    rreps(i, n - 1){
        g[i].push_back({i - 1, 0LL});
    }

    rep(i, m){
        int l, r;
        lint c;
        cin >> l >> r >> c;
        g[--l].push_back({--r, c});
    }

    vector<lint> cost(n, LLINF);
    cost[0] = 0;
    priority_queue<node> que;
    que.push({0, 0LL});

    while(!que.empty()){
        node now = que.top();
        que.pop();
        if(cost[now.id] < now.cost){
            continue;
        }
        for(auto e : g[now.id]){
            if(chmin(cost[e.to], now.cost + e.cost)){
                que.push({e.to, now.cost + e.cost});
            }
        }
    }

    if(cost[n - 1] < LLINF){
        cout << cost[n - 1] << endl;
    }else{
        cout << -1 << endl;
    }

    cout << flush;

    return 0;
}

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

const int MAX_N = 1e+5 + 1;

int a[MAX_N], b[MAX_N], c[MAX_N], dp[MAX_N][3];

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> a[i] >> b[i] >> c[i];
    for (int i = 0; i < 3; i++) dp[0][i] = 0;
    for (int i = 1; i <= N; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(void)
{
    int i, j, judge=0;
    int X, Y;

    scanf("%d", &X);
    scanf("%d", &Y);

    for(i=0; i<=X; i++) {
        for(j=0; j<=X-i; j++){
            if(i*2 + j*4 == Y && i+j == X) {
                judge = 1;
                break;
            }
        }
        if(judge == 1) {
            break;
        }
    }
    if (i==0 && j==0) {
        judge = 0;
    }

    if (judge == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1648
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int w=scan.nextInt();
		int h=scan.nextInt();
		int x=scan.nextInt();
		int y=scan.nextInt();
		int r=scan.nextInt();
		if(0<=x-r && x+r<=w &&0<=y-r && y+r<=h)System.out.println("Yes");
		else System.out.println("No");
        scan.close();
	}

}


Measured memory_bytes: 26272
n, y = map(int, input().split())
y //= 1000
ans = [-1, -1, -1]
for i in range(y // 10 + 1):
    for j in range((y - i * 10) // 5 + 1):
        k = y - i * 10 - j * 5
        if i + j + k == n:
            ans = [i, j, k]
print(*ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	string S;
	cin>>S;
	int ans = 0;
	for(int i=0;i<S.size()/2;i++){
		if(S[i] != S[S.size()-1-i])ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    //-1000000到1000000
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int x=sc.nextInt();
        int left= (x-k+1<-1000000 ? -1000000:x-k+1);
        int right=(x+k-1>1000000? 1000000:x+k-1);
        for(int i=left;i<=right;i++){
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
ll gcd(ll a,ll b){//最大公約数
  if (a%b==0){
		return(b);
    }
	else{
		return(gcd(b,a%b));
    }
}
int main(void){
  ll n,x;
  cin>>n>>x;
  vl a(n);
  rep(i,n){cin>>a[i];}
  a.pb(x);
  ll ans=(ll)abs(a[1]-a[0]);
  rep(i,n-1){
  	ans=gcd(ans,(ll)abs(a[i+2]-a[i+1]));
  }
  cout<<ans;
  return 0;
}

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

int bitIsOne(int z,int bit_number){
    if((z>>bit_number)&1) return 1;
    else return 0;

}

int main(void){

    int H,W,K;
    int i,j,black=0,white=0;
    int hbits=0,wbits=0,count=0;
    char board[6][7]={};

    scanf("%d",&H);
    scanf("%d",&W);
    scanf("%d",&K);
    for(i=0;i<H;i++){
        scanf("%s",board[i]);
    }

    for(hbits=0;hbits<pow(2,H);hbits++){
        for(wbits=0;wbits<pow(2,W);wbits++){
            black=0;
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if(board[i][j]=='#'&& bitIsOne(hbits,i) && bitIsOne(wbits,j)) black++;
                }
            }
            if(black==K) count++;
        }
    }
    
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int gcd(int a, int b)
{
  int r = a % b;
  if(r==0){
    return b;
  }else{
    return gcd(b, r);
  }
}

int main()
{
  int n, X;
  cin >> n >> X;
  vi x(n);
  for (int &i : x)
  {
    cin >> i;
  }
  x.push_back(X);
  sort(x.begin(), x.end());
  vi d(n);
  rep(i, n)
  {
    d.at(i) = x.at(i + 1) - x.at(0);
  }
  int ans = d.at(0);
  rep(i, n)
  {
    ans = gcd(ans, d.at(i));
  }
  cout << ans << endl;
  return 0;
}

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

void solve() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> W(N+1, 0);
    for (ll i = 0; i < N; ++i) {
        ll x;
        cin >> x;
        A[i] = x;
        W[x] += 1;
    }
    ll all = 0;
    for (ll w: W) {
        all += w * (w - 1) / 2;
    }

    for (ll i = 0; i < N; ++i) {
        ll x = A[i];
        ll n = W[x];
        ll count = n * (n - 1) / 2 - (n - 1) * (n - 2) / 2;
        cout << (all - count) << endl;
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 5760
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
		int N;
		cin>>N;
		vector<int>a,c;
		for(int i=0;i<N;i++){
			int k;
			cin>>k;
			a.push_back(k);
		}
		int sol=0;
		for(int i=0;i<N;i++){
			int k;
			cin>>k;
			sol+=k;
		}
		for(int i=0;i<N-1;i++){
			int k;
			cin>>k;
			c.push_back(k);
		}
		for(int i=0;i<N-1;i++){
			if(a[i+1]==a[i]+1)sol+=c[a[i]-1];
		}
		cout<<sol;
		return 0;
}


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

int main()
{

	while(true){

		int n;
		int m=0,e=0,j=0;

		cin >> n;

		if(n==0)
			break;

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

			cin >> m >> e >> j;
			

			if(m == 100 || e == 100 || j == 100)
				cout << 'A' << endl;

			else if((m + e)/2 >= 90)
				cout << 'A' << endl;

			else if((m + e + j)/3 >= 80)
				cout << 'A' << endl;
		
			else if((m + e + j)/3 >= 70)
				cout << 'B' << endl;
		
			else if((m + e + j)/3 >= 50 && (m >=80 || e >= 80))
				cout << 'B' << endl;
		
			else
				cout << 'C' << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int x;  cin >> x;
    if (x >= 30)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) cin >> grid[i];
    for (int i = 0; i < h; ++i) {
        bool can = true;
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == '#') {
                can = false;
                break;
            }
        }
        if (can) for (int j = 0; j < w; ++j) grid[i][j] = '$';
    }
    for (int j = 0; j < w; ++j) {
        bool can = true;
        for (int i = 0; i < h; ++i) {
            if (grid[i][j] == '#') {
                can = false;
                break;
            }
        }
        if (can) for (int i = 0; i < h; ++i) grid[i][j] = '$';
    }
    for (int i = 0; i < h; ++i) {
        bool flag = true;
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] != '$') {
                flag = false;
                cout << grid[i][j];
            }
        }
        if (!flag) cout << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0
count2=0

m=int(input())
for i in range(m):
    d,c=map(int,input().split())
    count+=d*c//9
    count2+=d*c%9
    ans+=c
print(ans-1+(count+(count2-1)//9))



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

typedef pair<string, int> P;

signed main() {
	int n, q;
	cin >> n >> q;
	queue<P> que;

	for (int i = 0; i < n; ++i) {
		string name;
		int time;
		cin >> name >> time;
		que.push(make_pair(name, time));
	}

	int cnt = 0;

	while (!que.empty()) {
		if (que.front().second > q) {
			que.front().second -= q;
			que.push(que.front());
			que.pop();
			cnt += q;
		}
		else {
			cnt += que.front().second;
			cout << que.front().first << ' ' << cnt << endl;
			que.pop();
		}
	}
}



Measured memory_bytes: 6320
s = input()
ans=0
for a in [[0,1,2,3],[0,2,1,3],[0,3,2,1],[1,2,0,3],[1,3,0,2],[2,3,1,0]]:
    if s[a[0]] == s[a[1]] and s[a[2]]==s[a[3]] and s[a[0]]!=s[a[2]]:
        ans = 1

if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
h, w = map(int, input().split())
n = int(input().strip())
a = list(map(int, input().split()))
ans = []
tmp = []
for i in range(n):
    tmp += [(i + 1)] * a[i]
for i in range(len(tmp) // w):
    ans.append(tmp[i * w:(i + 1) * w])
odd = True
for elem in ans:
    if odd:
        print(*elem)
        odd = False
    else:
        print(*elem[::-1])
        odd = True


Measured memory_bytes: 41712
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]
last = [0 for i in range(26)]
sat = 0

for d in range(D):
  sat += s[d][t[d]-1]
  last[t[d]-1] = d+1
  for i in range(26):
    sat -= c[i] * (d+1 - last[i])
  print(sat)

Measured memory_bytes: 9152
#include<stdio.h>
  int main(void)
  {
    int n,x,r=1<<29;
    for(scanf("%d",&n);n--;){
     int r0=0;
      scanf("%d",&x);
      for(;x%2<1;x/=2)r0++;
      if(r>r0)r=r0;
    }
    printf("%d\n",r);
    return 0;
  }


Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A, B = MAP()
P = LIST()

c = [0] * 3
for i in range(N):
    if P[i] <= A:
        c[0] += 1
    elif A+1 <= P[i] <= B:
        c[1] += 1
    else:
        c[2] += 1
print(min(c))


Measured memory_bytes: 5524
import java.util.*;

public class Main {

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

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int count = 0;

        for(int i = 0; i < 3; i++){
            if(s[i] == t[i]){
                count++;
            }
        }

        System.out.println(count);
    }
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int x = in.ni(), y = in.ni(), z = in.ni();
        int ans = x/(y+z);
        if(x-x/(y+z)*(y+z)<z) ans--;
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int A,B;	cin>>A>>B;
	if(A<10&&B<10)	cout<<A*B<<endl;
	else			cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    long long int ans = 0;
    if(k <= a){
        ans = k;
    }else if(k <= (a+b)){
        ans = a;
    }else{
        ans = a - (k-a-b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int a[123];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  int cnt = 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1]) {
      ++cnt;
    } else {
      ans += cnt / 2;
      cnt = 1;
    }
  }
  ans += cnt / 2;
  cout << ans << endl;
}


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

using namespace std;

int main(){
    string b;
    cin >> b;
    for(int i=0;i<b.size();i++){
        if(b[i]=='A'){
            cout << 'T' << endl;
        }else if(b[i]=='T'){
            cout << 'A' << endl;
        }else if(b[i]=='G'){
            cout << 'C' << endl;
        }else{
            cout << 'G' << endl;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int N, M, C;
    scanf("%d %d %d", &N, &M, &C);
    int A[N][M], B[M];
    for(int i = 0; i < M; i++){
        scanf("%d", &B[i]);
    }
    for(int i = 0; i < N; i ++){
        for(int j = 0; j < M; j++){
            scanf("%d", &A[i][j]);
        }
    }

    int count = 0;
    int sum;
    for(int i = 0; i < N; i++){
        sum = 0;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        if(sum + C > 0){
            count++;
        }
        
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
int p[1<<17],n,s,i;
main(){p[1]=1;for(i=2;i*i<1<<17;i++)if(!p[i])for(s=2;i*s<1<<17;s++)p[i*s]++;for(;scanf("%d",&n),n;printf("%d\n",s))for(i=2,s=0;(!p[i])?s+=i,n--:n,n;i++);}

Measured memory_bytes: 0
class Queue:
    def __init__(self):
        self.Q = [[] for _ in range(100000)]
        self.head = 0
        self.tail = 0
    def enqueue(self, x):
        self.Q[self.tail] = x
        if self.tail == 99999:
            self.tail = 0
        else:
            self.tail += 1
    def dequeue(self):
        if self.head == 99999:
            self.head = 0
        else:
            self.head += 1
        return self.Q[self.head-1]
    def len(self):
        return self.tail - self.head

nameQ = Queue()
timeQ = Queue()


N, q = map(int, input().split())
for i in range(N):
    namei, timei = input().split()
    timei = int(timei)
    timeQ.enqueue(timei)
    nameQ.enqueue(namei)
time = 0
while nameQ.len() != 0:
    namei = nameQ.dequeue()
    timei = timeQ.dequeue()
    if timei <= q:
        time += timei
        print(namei, time)
    else:
        time += q
        timei -= q
        nameQ.enqueue(namei)
        timeQ.enqueue(timei)


Measured memory_bytes: 20084
"use strict";

const main = arg => {
   const input = arg.trim().split("\n").map(el => Array.from(el));
   let n = 0;
   input[0].forEach((el, i) => {
   	if(el !== input[1][i]) n++;
   });
  console.log(n);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

public class Main {
	public static void main (String[] args){
	Scanner sc=new Scanner(new InputStreamReader(System.in));
	int a=sc.nextInt();
	int b=sc.nextInt();
	int c=sc.nextInt();
	sc.close();
	int x=0;
	for(int i=a;i<=b;i++){
		if(c%i==0) x++;
	}
	System.out.println(x);
	}
}

Measured memory_bytes: 26316
N,K = map(int, input().split())
A = [*map(lambda x:int(x)-1, input().split())]

pre = 0
index = [-1]*N
path = []
for n in range(N):
    if index[pre] >= 0:
        # print('len(path)',len(path),'pre',pre)
        # print('n',n,'index[pre]',index[pre])
        # print('index',index)
        # print('path',path)
        break
    else:
        index[pre] = n
        path += [pre]
    pre = A[pre]

loops = len(path) - index[pre]
one = len(path) - loops
k = max(0, K-one) % loops + min(K, one)
# print('one',one,'loops',loops,'k',k)

pre = 0
for _ in range(k): pre = A[pre]
print(pre + 1)


Measured memory_bytes: 32372
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	if(n != 1){
			System.out.println((long)Math.pow(k - 1, n - 1) * k);
        }else{
          	System.out.println(k);
        }
	}
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x,add,sum,all=1,a[305],dp[305][90005],dp2[305][90005],mod=998244353;
int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	for(int i=1;i<=n;i++)
		all=(all*3)%mod;
	dp[1][a[1]]+=1,dp[1][0]+=2,dp2[1][a[1]]+=1,dp2[1][0]+=1;
	for(int j=2;j<=n;j++)
		for(int i=0;i<=sum;i++){
			dp[j][i]=(dp[j][i]+(dp[j-1][i]*2))%mod;
			dp2[j][i]=(dp2[j][i]+dp2[j-1][i])%mod;
			if(i+a[j]<=90000){
				dp[j][i+a[j]]=(dp[j][i+a[j]]+dp[j-1][i])%mod;
        		dp2[j][i+a[j]]=(dp2[j][i+a[j]]+dp2[j-1][i])%mod;
			}
		}
	for(int i=ceil(sum/2.0);i<=sum;i++)
		x=(x+dp[n][i])%mod;
	x=(x*3)%mod;
	if(sum%2==0)add=(dp2[n][sum/2])*3%mod;
	ll ans=((all-(x-add)%mod)+mod)%mod;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef pair<int,int> pii;

int N, M;
pii PD[10010];

int main() {
  while (true) {
    scanf("%d %d", &N, &M);
    if (N == 0 && M == 0) break;
    for (int i=0;i<N;i++) {
      int D, P;
      scanf("%d %d", &D, &P);
      PD[i] = pii(-P, D);
    }
    sort(PD, PD+N);
    int idx = 0;
    while (M > 0 && idx < N) {
      if (PD[idx].second >= M) {
        PD[idx].second -= M;
        break;
      }
      M -= PD[idx++].second;
    }
    int ans = 0;
    for (int i=idx;i<N;i++) ans += -PD[i].first*PD[i].second;
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2644
/**
 * Created by hiramekun at 20:53 on 2020-04-26.
 */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define each(i, mp) for(auto& i:mp)

int main() {
    string s;
    cin >> s;
    map<ll, ll> mp;
    mp[0] = 1;
    reverse(s.begin(), s.end());
    ll now = 0, ten = 1;
    each(e, s) {
        now = (now + (e - '0') * ten) % 2019;
        ten *= 10;
        ten %= 2019;
        mp[now]++;
    }
    ll ans = 0;
    each(e, mp) {
        ans += e.second * (e.second - 1) / 2;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3764
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        for(int i = a;i <= b;i++){
            if(i >= a+k && i <= b-k){
                continue;
            }
            System.out.println(i);
        }
    }
}


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

int main(){
  int n,t; cin >> n >> t;
  int a[n][2],i,j;
  int c_min;

  for (i=0; i<n; i++){
    cin >> a[i][0] >> a[i][1];
  }
  c_min = 1001;
  for (i=0; i<n; i++){
    if( a[i][1] <= t && c_min > a[i][0]){
      c_min = a[i][0];
    }
  }
  if ( c_min != 1001){
    cout << c_min << endl;
  }
  else cout << "TLE" <<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>

using namespace std;

int main()
{
    long long n;
    cin >> n;
    long long ans = 0;
    for (long long i = 1;i <= n;i++){
        if (i%3 == 0 || i%5 == 0){
            ;
        }
        else {
            ans = ans + i;
        }
    }
    cout << ans << endl;
}


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

ll ebob(ll a, ll b){
	if(a == 0) return b;
	return ebob(b%a, a);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n; cin>>n;
	if(n%2){
		cout<<0;
		return 0;
	}else{
		n = n/2;
		ll res = 0;
		while(n > 0){
			res += n/5;
			n /= 5;
		}
		cout<<res;
	}
	return 0;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
typedef long long ll;
typedef unsigned long long ull;
int n,m;
vector<int> v[100001];
int vis[100001];
int sig[100001];
void bfs(int root){
	queue<int> q;
	q.push(root);
	while(q.size()!=0){
		int si=q.size();
		while(si--){
			int ele=q.front();
			q.pop();
			for(int child: v[ele]){
				if(vis[child]==0){
					vis[child]=1;
					q.push(child);
					sig[child]=ele;
				}
			}
		}
	}

}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n,m,a,b;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	sig[1]=1;
	vis[1]=1;
	bfs(1);
/*	for(int i=2;i<=n;i++){
		if(sig[i]==0){
			cout<<"No\n";
			return 0;
		}
	}*/
	cout<<"Yes\n";
	for(int i=2;i<=n;i++){
		cout<<sig[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 10912
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


typedef set<int> Group;

Group* make_group(int num){
	Group *new_group = new Group();
	new_group->insert(num);
	return new_group;
}

Group* merge(Group* left,Group* right){
	if(left->size() < right->size()){
		swap(left,right);
	}
	for(Group::iterator it = right->begin(); it != right->end(); it++)left->insert(*it);

	return left;
}

int main(){

	int N;
	scanf("%d",&N);
	queue<Group*> Q;

	vector<int> V,WORK;

	int tmp;
	map<int,int> MAP;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		V.push_back(tmp);
		WORK.push_back(tmp);
	}

	sort(WORK.begin(),WORK.end());

	for(int i = 0; i < N; i++){
		MAP[WORK[i]] = i+1;
	}
	for(int i = 0; i < N; i++){
		V[i] = MAP[V[i]];
	}

	for(int i = 0; i < N; i++){
		Q.push(make_group(V[i]));
	}

	ll ans = 0;
	for(int num = 1; num <= N; num++){
		Group* group = Q.front();
		Q.pop();

		while(true){
			if(*(group->begin()) == num){
				group->erase(group->begin());
				ans += group->size();
				if(group->size() > 0){
					Q.push(group);
				}
				break;
			}
			Group* next_group = Q.front();
			Q.pop();
			group = merge(group,next_group);
		}
	}

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

	return 0;
}



Measured memory_bytes: 49808
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    
    while(1){
        cin >> n;
        if (n == 0) break;
        int sum = 0;
        double m, sum2 = 0, ans;
        vector<int> si(n);
        for (int i=0; i<n; i++){
            cin >> si.at(i);
            sum += si.at(i); 
        }
        m = 1.0 * sum / n;
        for (int x : si){
            sum2 += pow(x - m , 2);
        }
        ans = sqrt(sum2 / n);
        cout << fixed << setprecision(7) << ans << endl;
    }
    return 0; 



}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, M, C, ans = 0; cin >> N >> M >> C;
    vector<int> B;
    rep (i, 0, M) {
        int b; cin >> b;
        B.push_back(b);
    }
    rep (i, 0, N) {
        int tmp = C;
        rep (j, 0, M) {
            int a; cin >> a;
            tmp += a*B[j];
        }
        if (tmp > 0) ++ans;
    }
    cout << ans << endl;
}

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


public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader bufReader =
				new BufferedReader(new InputStreamReader(System.in));
		String str = bufReader.readLine();
		char[] strChars = str.toCharArray();
		for (int i = 0; i < str.length()/2; i++) {
			char left = strChars[i];
			char right = strChars[str.length() - i - 1];
			strChars[i] = right;
			strChars[str.length() - i - 1] = left;
		}
		String result = new String(strChars);
		System.out.println(result);
	}

}

Measured memory_bytes: 16864
// CppPractice.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
	int a;
	string s;
	cin >> a;
	cin >> s;

	if (a >= 3200) cout << s;
	else cout << "red";
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define EPS (1e-10)    //誤差
typedef complex<double> P;

//実数同士の比較
bool EQ(double a, double b){
    return (abs(a - b) < EPS);
}

//内積
double dot(P a, P b){
    return (a.real() * b.real() + a.imag() * b.imag());
}

//外積
double cross(P a, P b){
    return (a.real() * b.imag() - a.imag() * b.real());
}

int main(){

    int q; cin >> q;
    for(int i = 0; i < q; i++){
        P p0, p1, p2, p3; cin >> p0.real() >> p0.imag() >> p1.real() >> p1.imag() >> p2.real() >> p2.imag() >> p3.real() >> p3.imag();
        int ans = 0;
        //垂直だったら内積0
        if(EQ(dot(p1 - p0, p3 - p2), 0.0)) ans = 1;
        else if(EQ(cross(p1 - p0, p3 - p2), 0.0)) ans = 2; 
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3204
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map{it.toInt()}
    val sum = list.sum()
    var num = 0
    var result = sum
    for(i in 0..n-1){
        num += list[i]
        if(Math.abs((sum-num)-num)<result){
            result = Math.abs((sum-num)-num)
        }
    }
    println(result)
}

Measured memory_bytes: 36076
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

int main(){
    Int N, X; cin >> N >> X;
    cout << 3*(N - gcd(N, X)) << endl;
}


Measured memory_bytes: 256