akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int N = 100010;

int n;
int aa, bb;
int cnt[N];
int a[N][2];
bool was[N];
vector< pair< pair<int, int>, int > > y[2];
set< pair< pair<int, int>, int > > z[2];

int calc(int i, int j) {
  return max(abs(a[i][0] - a[j][0]), abs(a[i][1] - a[j][1]));
}

int main() {
  scanf("%d %d %d", &n, &aa, &bb);
  aa--; bb--;
  for (int i = 0; i < n; i++) {
    int xx, yy;
    scanf("%d %d", &xx, &yy);
    a[i][0] = xx + yy;
    a[i][1] = xx - yy;
    for (int rot = 0; rot < 2; rot++) {
      z[rot].insert(make_pair(make_pair(a[i][rot], a[i][1 - rot]), i));
    }
  }
  for (int rot = 0; rot < 2; rot++) {
    y[rot] = vector< pair< pair<int, int>, int > >(z[rot].begin(), z[rot].end());
  }
  int want = calc(aa, bb);
  for (int i = 0; i < n; i++) {
    for (int rot = 0; rot < 2; rot++) {
      for (int sgn = -1; sgn <= 1; sgn += 2) {
        vector< pair< pair<int, int>, int > >::iterator low =
          lower_bound(y[rot].begin(), y[rot].end(), make_pair(make_pair(a[i][rot] + sgn * want, a[i][1 - rot] - want), -1));
        vector< pair< pair<int, int>, int > >::iterator high =
          upper_bound(y[rot].begin(), y[rot].end(), make_pair(make_pair(a[i][rot] + sgn * want, a[i][1 - rot] + want), n));
        cnt[i] += (int)(high - low);
      }
    }
    for (int sgn_x = -1; sgn_x <= 1; sgn_x += 2) {
      for (int sgn_y = -1; sgn_y <= 1; sgn_y += 2) {
        int xx = a[i][0] + sgn_x * want;
        int yy = a[i][1] + sgn_y * want;
        vector< pair< pair<int, int>, int > >::iterator it = 
          lower_bound(y[0].begin(), y[0].end(), make_pair(make_pair(xx, yy), -1));
        if (it != y[0].end() && it->first.first == xx && it->first.second == yy) {
          cnt[i]--;
        }
      }
    }
  }
  queue<int> que;
  que.push(aa);
  was[aa] = true;
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int rot = 0; rot < 2; rot++) {
      for (int sgn = -1; sgn <= 1; sgn += 2) {
        set< pair< pair<int, int>, int > >::iterator low = 
          z[rot].lower_bound(make_pair(make_pair(a[v][rot] + sgn * want, a[v][1 - rot] - want), -1));
        set< pair< pair<int, int>, int > >::iterator high = 
          z[rot].upper_bound(make_pair(make_pair(a[v][rot] + sgn * want, a[v][1 - rot] + want), n));
        for (set< pair< pair<int, int>, int > >::iterator it = low; it != high; it++) {
          int u = it->second;
          if (!was[u]) {
            was[u] = true;
            que.push(u);
          }
        }
        z[rot].erase(low, high);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (was[i]) {
      ans += cnt[i];
    }
  }
  printf("%lld\n", ans / 2);
  return 0;
}


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

	#define E "\n"
	#define int long long 
	#define f(i,l,n) for(int i=l;i<n;i++)




	int solve()
	{
		int a,b,c,k;
		cin >>a >> b >> c >> k;

		if(k<=a+b) cout<<min(a,k)<<E;
		else 
		{
			int temp=a;
			k-=a+b;
			cout<<temp-k<<E;
		}


		return 0;
	}

		


		int32_t main()
		{

		 	int t=1;
		 	//cin >> t;
		 	while(t--)
		 	{
		 		solve();
		 	}

		}

Measured memory_bytes: 3624
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

A.sort(key=lambda x:x[1])

ans = 1
end = A[0][1]
for i in range(1,M):
    if A[i][0]>=end:
        ans += 1
        end = A[i][1]
print(ans)

Measured memory_bytes: 29084
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (100006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n,m; ll s,t;
vector<int>v[MAXN];
ll vis[MAXN][3];
// void dfs(ll x,ll val,ll d){
	// if(~vis[x][val])return; vis[x][val]=d;
	// if(x==t&&val==0){
		// assert(d%3==0);cout<<d/3<<'\n'; exit(0);
	// }
	// for(auto i:v[x]){
		// dfs(i,(val+1)%3,d+1);
	// }
// }
int main()
{
	FAST
	cin>>n>>m;
	FOR(i,0,m){
		ll a,b;cin>>a>>b;
		v[a].pb(b);
	}
	cin>>s>>t;
	mmst(vis,-1);
	queue<pi>q;
	q.emplace(s,0); vis[s][0]=0;
	while(q.size()){
		ll x=q.front().f,d=q.front().s;
		q.pop();
		for(auto i:v[x]){
			if(vis[i][(d+1)%3]==-1||vis[i][(d+1)%3]>d+1){
				vis[i][(d+1)%3]=d+1;
				q.emplace(i,d+1);
			}
		}
	}
	if(~vis[t][0])cout<<vis[t][0]/3<<'\n';
	else cout<<"-1\n";
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define nl '\n'
#define ff first
#define ss second
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0); srand(time(0));

  int tc = 1; // cin >> tc;
  while(tc--) {
    int n; cin >> n;
    int a[1+n];
    for(int i=1; i<=n; i++) {
      cin >> a[i];
    }
    int N = 10000;
    int ans = 0;
    for(int i=2; i<=n; i++) {
      if( a[i] == a[i-1] ) {
	a[i] = N--;
	ans++;
      }
    }
    cout << ans << nl;    
  }

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 256
from bisect import bisect_left


def main():
    n = int(input())
    lst = [int(input()) for _ in range(n)]
    print(lis(lst))


def lis(A: list):
    L = [A[0]]
    for a in A[1:]:
        if a > L[-1]:
            L.append(a)
        else:
            L[bisect_left(L, a)] = a
    return len(L)


if __name__ == '__main__':
    main()



Measured memory_bytes: 11156
N=int(input())
A1= list(map(int, input().split()))
A2= list(map(int, input().split()))
ans = [0]*N
for i in range(N):
  ans[i] += sum(A1[:i+1])
  #print(i,':', 'sum:',ans[i])
  ans[i] += sum(A2[i:])
  #print(i,':', 'sum:',ans[i])
print(max(ans))


Measured memory_bytes: 2940
def main():
    import sys
    input = lambda : sys.stdin.readline().rstrip()

    from heapq import heappush, heappop 

    running = []
    events = []
    delete = set()

    n, q = map(int, input().split())
    for _ in range(n):
        s, t, x = map(int, input().split())
        time = max(s - x, 0)
        if t - x < 0:
            continue
        events.append((s - x, x, 1)) # 追加イベント
        events.append((t - x, x, 0)) # 削除イベント
    events.sort()
    ans = []
    idx = -1
    for _ in range(q):
        d = int(input())
        if d >= events[-1][0]:
            print(-1)
            continue
        while events[idx + 1][0] <= d:
            idx += 1
            if events[idx][2] == 1:
                heappush(running, events[idx][1])
                delete.discard(events[idx][1])
            else:
                delete.add(events[idx][1])
        flag = 1
        while running:
            x = heappop(running)
            if x not in delete:
                heappush(running, x)
                print(x)
                flag = 0
                break
        if flag:
            print(-1)
if __name__ == '__main__':
    main()





Measured memory_bytes: 69604
print ("1x1=1")
print ("1x2=2")
print ("1x3=3")
print ("1x4=4")
print ("1x5=5")
print ("1x6=6")
print ("1x7=7")
print ("1x8=8")
print ("1x9=9")
print ("2x1=2")
print ("2x2=4")
print ("2x3=6")
print ("2x4=8")
print ("2x5=10")
print ("2x6=12")
print ("2x7=14")
print ("2x8=16")
print ("2x9=18")
print ("3x1=3")
print ("3x2=6")
print ("3x3=9")
print ("3x4=12")
print ("3x5=15")
print ("3x6=18")
print ("3x7=21")
print ("3x8=24")
print ("3x9=27")
print ("4x1=4")
print ("4x2=8")
print ("4x3=12")
print ("4x4=16")
print ("4x5=20")
print ("4x6=24")
print ("4x7=28")
print ("4x8=32")
print ("4x9=36")
print ("5x1=5")
print ("5x2=10")
print ("5x3=15")
print ("5x4=20")
print ("5x5=25")
print ("5x6=30")
print ("5x7=35")
print ("5x8=40")
print ("5x9=45")
print ("6x1=6")
print ("6x2=12")
print ("6x3=18")
print ("6x4=24")
print ("6x5=30")
print ("6x6=36")
print ("6x7=42")
print ("6x8=48")
print ("6x9=54")
print ("7x1=7")
print ("7x2=14")
print ("7x3=21")
print ("7x4=28")
print ("7x5=35")
print ("7x6=42")
print ("7x7=49")
print ("7x8=56")
print ("7x9=63")
print ("8x1=8")
print ("8x2=16")
print ("8x3=24")
print ("8x4=32")
print ("8x5=40")
print ("8x6=48")
print ("8x7=56")
print ("8x8=64")
print ("8x9=72")
print ("9x1=9")
print ("9x2=18")
print ("9x3=27")
print ("9x4=36")
print ("9x5=45")
print ("9x6=54")
print ("9x7=63")
print ("9x8=72")
print ("9x9=81")


Measured memory_bytes: 5604
#include <iostream>
using namespace std;
int main(){

int a,b,c,d,e,f;

cin>>a>>b>>c>>d>>e;
     if(a<40) a=40;
     if(b<40) b=40;
     if(c<40) c=40;
     if(d<40) d=40;
     if(e<40) e=40;

     f=(a+b+c+d+e)/5;

cout <<f<<endl;



return 0;
}



Measured memory_bytes: 3092
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int array[] = new int[n];
    for(int a=0;a<n;a++){
      array[a]=sc.nextInt();
    }
    Arrays.sort(array);
    int count = 0;
    for(int b=n-k;b<n;b++){
      count += array[b];
    }
    System.out.println(count);
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> A(n, vector<int>(n));
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> A[i][j];
    int p = int(1e9) + 7;

    vector<int> DP(1 << n, 0);
    DP[0] = 1;

    for (int S = 1; S < 1 << n; S++){
        int i = __builtin_popcount(S) - 1;
        int s = 0;
        for (int j = 0; j < n; j++)
            if (A[i][j]) s = (s + DP[S & ~(1 << j)]) % p;
        DP[S] = s;
    }

    cout << DP[(1 << n) - 1] << endl;
}

Measured memory_bytes: 8448
using System;using System.Linq;
class A{
    static void Main(){string []ns=Console.ReadLine().Split();
    int n=int.Parse(ns[0]);
    int max=0;
    for(int i=0;i<n;i++){
        max=Math.Max(max,Console.ReadLine().Split().Select(int.Parse).ToArray().Sum());
    }
    Console.WriteLine(max);
    }
}

Measured memory_bytes: 9608
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($n,$m,$d) = explode(" ",trim(fgets(STDIN)));
$a = explode(" ",trim(fgets(STDIN)));

$res = 0;
foreach($a as $v) {
  $res += $v-1;
}
printf("%d\n",$res);


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

int main() {
    vector<int> A(3);
    for (int i=0; i<3; i++) cin >> A.at(i);
    
    int sum = 0;
    for (int i=0; i<3; i++) sum += A.at(i);

    if (sum>=22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll digit_sum(ll n) {
    if (n < 10) return n;
    return digit_sum(n / 10) + n % 10;
}
#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s, t; cin >> s >> t;
    int SL = s.size();
    int TL = t.size();

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    string ans = "No";
    if ((s[0] < t[TL-1]) 
     || ((SL < TL) && (s==t.substr(0,SL)))) ans="Yes";

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string r = "";
    for(int i = 0;i < s.size();i++){
        r += s.at(i);
        r += t.at(i);
    }
    cout << r << endl;
}

Measured memory_bytes: 256
N = int(input())

map = {}
count = 0
for i in range(0, N):
    strings = list(input())
    strings.sort()
    key = "".join(strings)
    if not key in map:
        map[key] = 1
    else:
        count += map[key]
        map[key] += 1

print(count)

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

struct edge { int to, cost; };

typedef pair<long long, int> plli;
int main() {
  int n, m;
  cin>>n>>m;

  long long d[n][n];
  long long inf = 2*1e9;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = inf;
      }
    }
  }
  for (int i=0; i<m; i++) {
    int s, t, dist;
    cin>>s>>t>>dist;
    d[s][t] = dist;
  }
  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if (d[i][k] != inf && d[k][j] != inf) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
  }
  for (int i=0; i<n; i++) {
    if (d[i][i] < 0) {
      cout<<"NEGATIVE CYCLE"<<endl;
      return 0;
    }
  }
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      long long dij = d[i][j];
      if (dij == inf) {
        cout<<"INF";
      } else {
        cout<<dij;
      }
      if (j != n - 1) {
        cout<<" ";
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3180
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    a,b=0,0
    for d in range(1,int(1+n**.5)):
        if(n%d==0):
            a,b=d,n//d
    print(a-1+b-1)
resolve()

Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

double A,B,H,M;

int main(){
	cin>>A>>B>>H>>M;
	printf("%.12f\n",sqrt(A*A+B*B-2*A*B*cos(2*3.141592653589793238462643383279*((M/60)-((H*60+M)/720)))));
}


Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
char c[52][52];
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
int main()
{
	int n,m;
	cin>>n>>m;
	memset(c,'.',sizeof(c));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>c[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(c[i][j]=='#')
			{
				bool can=0;
				for(int k=0;k<4;k++)
					if(c[dx[k]+i][dy[k]+j]=='#')
						can=1;
				if(!can)
				{
					cout<<"No";
					return 0;
				}
			}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;

signed main(){
	IOS();
	cin>>N>>X;
	int now = 0;
	int ans = 0;
	rep(i,0,N){
		int t;
		cin>>t;
		now+=t;
		if(now<=X)ans++;
	}
	cout<<ans+1<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int a1,a2,a3;
int main()
{
   cin >> a1 >> a2 >> a3;
   int sum=a1+a2+a3;
   if(sum>=22){
    printf("bust");
   }else printf("win");
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int ans = 0;
    rep(i, N) {
        if (i % 2 == 0) {
            ans += a[i];
        } else {
            ans -= a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split( )))
ans = [0]*n
for i in range(n,0,-1):
    tmp = a[i-1]
    for j in range(n//i,1,-1):##上から、下限2?
        tmp+=ans[i*j-1]
    ans[i-1] = tmp%2

#print(ans)
m = sum(ans)
print(m)###
if m:
    for i in range(n):
        if ans[i] ==1:
            print(i+1,end=" ")


Measured memory_bytes: 63708
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();
		if(a%2!=b%2) {
			System.out.println("IMPOSSIBLE");
			
		}else {
			System.out.println((a+b)/2);
		}
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    pair<int,int> p[n];
    for(int i=0;i<n;i++){
        int x,l;
        cin>>x>>l;
        p[i]={x+l,x-l};
    }
    sort(p,p+n);
    int ans=0;
    int t=-INF;
    for(int i=0;i<n;i++){
        if(t<=p[i].second){
            ans++;
            t=p[i].first;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
from itertools import product

N = int(input())
num_digits = len(str(N))

num_shichigosans = 0
for d in range(3, num_digits):
    for num_string in product(["3", "5", "7"], repeat=d):
        if len(set(num_string)) < 3:
            continue
        num_shichigosans += 1

for num_string in product(["3", "5", "7"], repeat=num_digits):
    if len(set(num_string)) < 3:
        continue
    num = int("".join(num_string))
    if num <= N:
        num_shichigosans += 1
print(num_shichigosans)


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

int main()
{
	int N,A[100010]={};
	int cnt=0;
	int ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
		cin >> A[i];
	
	sort(A,A+N);
	
	for(int i=0;i<N;i++)
	{
		cnt++;
		if(A[i]!=A[i+1])
		{
			ans+=(cnt%2);
			cnt=0;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll a[n]; zep(i, 0, n)cin >> a[i];

    ll mn = a[0], u = 1000 / a[0], m = 1000; 
    zep(i, 1, n){
        if(a[i - 1] > a[i]){
            m += u * (a[i - 1] - mn);
            u = m / a[i];
            mn = a[i];
        }
    }

    m += u * (a[n - 1] - mn);
    print(m)

    return 0;
}

Measured memory_bytes: 3604
n = int(input())
a = [int(x) for x in input().split()]
res = 0
cnt = 1

for i in range(0,n):
  if a[i] == cnt:
    cnt = cnt + 1
  else:
    res = res + 1
    
if (cnt - 1) == (n - res) and not res == n:
  print(res)
else:
  print(-1)

Measured memory_bytes: 26140
#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,num, a,b,rem1,temp=0,i,j,sum=0;
    scanf("%lld %lld %lld",&n,&a,&b);

    for(i=1;i<=n;i++)
    {
        temp=0;
        num=i;
        while(num!=0)

        {
            rem1=num%10;
            temp=temp+rem1;
            num=num/10;

        }


       if(temp>=a && temp<=b)
       {

           sum=sum+i;
       }

    }
    printf("%lld",sum);

    return 0;
}


Measured memory_bytes: 128
///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 100005
using namespace std;
int n;
ll h[N];
int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&h[i]);
    int ans=0;
    int x=0;
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            x++;
        }else{
            ans=max(ans,x);
            x=0;
        }
    }
    ans=max(ans,x);
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

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

  vector<int> left, right;
  left.push_back(0);
  right.push_back(0);
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    if(x < 0){
      left.push_back(abs(x));
    }else{
      right.push_back(x);
    }
  }

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

  int ans = 1e+9;
  for(int i = 0; i < left.size(); i++){
    int j = k - i; 
    if(j < 0 || right.size() <= j) continue;

    if(i == 0){
      ans = min(ans, right[j]);
    }else if(j == 0){
      ans = min(ans, left[i]);
    }else{
      ans = min(ans, left[i] + right[j] + min(left[i], right[j]));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<endl
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll calc(ll k,ll d) {
  return k*(k+1)/2*d;
}

const ll n=26;
ll c[n],q[444];
ll a[444][n];
set<ll> s[n];

ll solve(ll x,ll y) {
  ll ans=0;
  {
    ans-=a[x][q[x]];
    iter(s[q[x]]) it2=s[q[x]].lower_bound(x);
    iter(s[q[x]]) it1=it2,it3=it2;it1--,it3++;
    ans+=calc(*it2-*it1-1,c[q[x]]);
    ans+=calc(*it3-*it2-1,c[q[x]]);
    ans-=calc(*it3-*it1-1,c[q[x]]);
    s[q[x]].erase(it2);
  }
  {
    q[x]=y;
    s[q[x]].in(x);
    ans+=a[x][q[x]];
    iter(s[q[x]]) it2=s[q[x]].lower_bound(x);
    iter(s[q[x]]) it1=it2,it3=it2;it1--,it3++;
    ans-=calc(*it2-*it1-1,c[q[x]]);
    ans-=calc(*it3-*it2-1,c[q[x]]);
    ans+=calc(*it3-*it1-1,c[q[x]]);
  }
  return ans;
}

         
void Main() {
  srand((unsigned)time(NULL));
  int T;
  R T;
  rep(i,n) R c[i];
  rep(i,T)rep(j,n) R a[i][j];
  rep(i,n) s[i].in(-1),s[i].in(T);
  ll ans[T];
  mem(ans);
  rep(k,T) {
    ll M=0,x=0;
    rep(i,n) {
      if(M<a[k][i]) {
        M=a[k][i];
        x=i;
      }
    }
    q[k]=x;
    s[x].in(k);
    ans[k]=x;
  }
  clock_t t2=clock();
  for(int tt=0;;tt++) {
    ll e[2][3],sum=0;
    rep(i,2) {
      ll x=rand()%T,y=rand()%n;
      e[i][0]=q[x],e[i][1]=x,e[i][2]=y;
      sum+=solve(x,y);
    }
    if(sum<0) {
      rrep(i,2) {
        int x=e[i][1];
        s[q[x]].erase(x);
        q[x]=e[i][0];
        s[q[x]].in(x);
      }
    } else {
      rep(i,2) ans[e[i][1]]=e[i][2];
    }
    clock_t t3=clock();
    double t4=(double)(t3-t2)/CLOCKS_PER_SEC;
    if(tt>=2&&(double)t3/CLOCKS_PER_SEC+t4*2>1.900) break;
    t2=t3;
  }
  rep(i,T) pr(ans[i]+1);
}

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


Measured memory_bytes: 3736
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Dice d1=new Dice(br.readLine().split(" "));
		Dice d2=new Dice(br.readLine().split(" "));
		boolean match=false;
		for(int i=0;i<6;i++){
			for(int j=0;j<4;j++){
				d2.spinR();
				if(d1.match(d2)){
					match=true;
					break;
				}
			}
			if(match) break;
			if(i%2==0){
				d2.throwN();
			}else{
				d2.throwW();
			}
			if(d1.match(d2)){
				match=true;
				break;
			}
		}
		if(match){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	
	static class Dice {
		private String top,front,right,left,back,bottom;

		public Dice(String[] lbl){
			top=lbl[0];
			front=lbl[1];
			right=lbl[2];
			left=lbl[3];
			back=lbl[4];
			bottom=lbl[5];
		}
		
		public void throwN(){ String tmp=top; top=front; front=bottom; bottom=back; back=tmp; }
		public void throwS(){ String tmp=top; top=back; back=bottom; bottom=front; front=tmp; }
		public void throwE(){ String tmp=top; top=left; left=bottom; bottom=right; right=tmp; }
		public void throwW(){ String tmp=top; top=right; right=bottom; bottom=left; left=tmp; }
		public void spinR(){ String tmp=front; front=left; left=back; back=right; right=tmp; }

		public String getTop() { return top; }
		public String getFront() { return front; }
		public String getRight() { return right; }
		public String getLeft() { return left; }
		public String getBack() { return back; }
		public String getBottom() { return bottom; }
		
		public boolean match(Dice dice2){
			if(this.getTop().equals(dice2.getTop())&&this.getFront().equals(dice2.getFront())
					&&this.getRight().equals(dice2.getRight())&&this.getLeft().equals(dice2.getLeft())
					&&this.getBack().equals(dice2.getBack())&&this.getBottom().equals(dice2.getBottom())){
				return true;
			}else{
				return false;
			}
		}
	}
}

Measured memory_bytes: 17100
import java.util.Scanner;
import java.lang.Math;
public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	while (scan.hasNext()) {
	    String input = scan.nextLine();
	    String[] inputs = input.split(" ");
	    int height = Integer.parseInt(inputs[0]);
	    int width = Integer.parseInt(inputs[1]);
	    if (height == 0 && width == 0) {
		break;
	    }
	    printsharp(width);
	    for (int i = 0; i < height - 2; i++) {
		System.out.print("#");
		for (int j = 0; j < width - 2; j++) {
		    System.out.print(".");
		}
		System.out.println("#");
	    }
	    printsharp(width);
	    System.out.println();
	}
    }
    public static void printsharp(int width) {
	for (int i = 0; i < width; i++) {
	    System.out.print("#");
	}
	System.out.println();
    }
}

Measured memory_bytes: 37304
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC178
{
    class Program
    {
        static void Main(string[] args)
        {
          	var N = long.Parse(Console.ReadLine());
            var c = 1L;
            var mod = 1000000007L;
            var b = 1L;
            var a = 1L;
            for (int i = 0; i < N; i++)
            {
                c = (c * 8) % mod;
                b = (b * 9) % mod;
                a = (a * 10) % mod;
            }
            var ans = (a - ((2 * b) % mod - c)) % mod;
            if (ans >= 0) Console.WriteLine(ans);
            else Console.WriteLine(ans+mod);

        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n ;
    cin >> n ;
    vvint cnt(10,vint(10,0)) ;
    vint sum(n+1) ;
    sum[0] = 0 ;
    FOR(i,1,n+1){
        string s = TS(i) ;
        char sf = s[0] ;
        char sb = s[SZ(s)-1] ;
        if(sf==0 || sb==0){
            sum[i] = s[i-1] ;
            continue ;
        }
        sum[i] = sum[i-1]+ 2*cnt[sb-'0'][sf-'0'] ;
        if(sf==sb){
            sum[i]++ ;
        }
        cnt[sf-'0'][sb-'0']++ ;
    }
    
    cout << sum[n] <<endl ;

    return 0;
}


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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+') {
    cout << A + B << endl;
  }
  else if (op == '-') {
    cout << A - B << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{

int x,a;
cin>>x>>a;

if(x>=a)
    cout<<10<<endl;
else
    cout<<0<<endl;

 return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N;
int p[1010];


void makeP(){
	repe(i, 2, N){
		int n = i;
		repif(j, 2, j*j <= n)
			while(n%j == 0) p[j]++, n/=j;
		if(n != 1) p[n]++;
	}
}


int solve(){
	int ans = 1;
	rep(i, 0, 1000)
		if(p[i] != 0) ans = MUL(ans, p[i]+1);
	return ans;
}


signed main(){
	cin >> N;

	makeP();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
N, R = map(int, input().split())
if 2*R > N:
    R = N - R
P = [0] + list(map(int, input().split()))

L = []
Lapp = L.append
used = [False]*(N+1)
pre = 0
for i in range(1, N+1):
    cnt = 0
    while not used[i]:
        used[i] = True
        cnt += 1
        i = P[i]
    if cnt:
        Lapp(cnt)
table = [0]*(N+1)
for l in L:
    table[l] += 1
L = []
Lapp = L.append
for i in range(1, min(R,N//2)+1):
    x = table[i]
    if not x:
        continue
    if x == 1:
        Lapp(i)
    else:
        Lapp(i)
        p = 2
        while 2*p <= x:
            table[p*i] += 1
            p *= 2
        if x == p:
            Lapp(i)
        table[i*(x - p + 1)] += 1
H = 1
for l in L:
    H = H|(H<<l)
if H & 1<<R:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 40212
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int N;
vector<long long> a;


int main() {
    while (cin >> N) {
        a.resize(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        
        map<long long, pair<long long, long long> > ma; // index, num
        for (int i = 0; i < N; ++i) {
            if (ma.count(-a[i])) {
                ma[-a[i]].second++;
            }
            else {
                ma[-a[i]] = make_pair(i, 1);
            }
        }
        
        long long res[210000] = {0};
        
        long long cur = -ma.begin()->first;
        long long index = ma.begin()->second.first;
        long long con = ma.begin()->second.second;
        EACH(it, ma) {
            if (it == ma.begin()) continue;
            long long dif = cur + it->first;
            res[index] += dif * con;
            
            cur = -it->first;
            chmin(index, it->second.first);
            con += it->second.second;
        }
        res[0] += cur * N;
        
        for (int i = 0; i < N; ++i) {
            cout << res[i] << endl;
        }
    }
}




Measured memory_bytes: 9728
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n = int(input())#10 ** 5
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

count = [0] * (n)
for i in range(n + 1):
  count[A[i] - 1] += 1
  #print(count)
mm = count.index(max(count)) + 1
#print(mm)

m1 = A.index(mm)
m2 = A[m1 + 1:].index(mm) + m1 + 1
#print(m1, m2)

ans = [0] * (n + 1)
for i in range(n + 1):
  ans[i] = cmb(n + 1, i + 1, p) - cmb(n - m2 + m1, i, p)
  
for i in range(n + 1):  
  print(ans[i] % p)  
  


Measured memory_bytes: 167748
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    llong S; cin>>S;
    const int v=1000000000;
    cout<<0<<" "<<0<<" "<<v<<" "<<1<<" "<<(v-S%v)%v<<" "<<(S+(v-S%v)%v)/v<<endl;
    return  0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
suma=0
for i in range(n):
  suma+=a[i]
border=suma/(4*m)
chk=0
for i in range(n):
  if a[i]>=border:
    chk+=1
print("Yes" if chk>=m else "No")

Measured memory_bytes: 3064
abc = list(map(int, input().split()))
abc.sort()
# a<=b
a = max(abc) - abc[0]
b = max(abc) - abc[1]
ans = a
if (b-a)%2==0:
    ans += (b-a)//2
else:
    ans += (b-a)//2
    ans += 2
print(ans)

Measured memory_bytes: 3060
/*
 *  Author: mizo0203
 *  Problem: 0003
 *  Status: Accepted
 *  Submission Date: 2012/04/15 02:17:30
 */
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int n;
int tri[3];

void init() {
  scanf("%d", &n);
}

bool input() {

  if (!n--)
    return false; // 入力の終わり
  scanf("%d %d %d", &tri[0], &tri[1], &tri[2]);

  return true;
}

int main() {

  init();
  while (input()) {
    sort(tri, tri + 3);
    if (pow(tri[0], 2) + pow(tri[1], 2) == pow(tri[2], 2))
      printf("YES\n");
    else
      printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
#def calc():
    #summ  = sum(A)
    #print(summ)
    
    #low = summ / (4*M)
    #print(low)

    #newlist = [i for i in A if i >= low]
    #print(newlist)

    #num = len(newlist)
    #print(num)

    #if M <= num:
        #print ("Yes")
    #else:
        #print ("No")

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

#N, M = 5, 2
#A = [110, 2, 20, 10, 0]
#calc()

S = sum(A)
cnt = 0

for i in A:
    if i >= S / (4*M):
        cnt += 1
if cnt >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
n = gets.chomp.to_i
taro,hanako = 0,0
n.times do
  c1,c2 = gets.chomp.split(" ")
  if c1 > c2
    taro += 3
  elsif c1 < c2
    hanako += 3
  else
    taro,hanako = taro + 1,hanako +1
  end
end

puts "#{taro} #{hanako}"

Measured memory_bytes: 8752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <forward_list>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// sanitize: shift + f11
// debug: shift + f9

void A() {
    string S;

    cin >> S;

    if(S == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}

void B() {
    ll N, K;

    cin >> N >> K;

    vi snukes(N, 0);

    R1(K) {
        ll di;
        cin >> di;
        R2(j, di) {
            ll ai;
            cin >> ai;
            snukes[ai-1]++;
        }
    }

    ll tot = 0;
    for(auto e : snukes) {
        if(e == 0) {
            ++tot;
        }
    }

    cout << tot << endl;
}

int main()
{
    B();
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<b&&b<c){
	cout<<a<<" "<<b<<" "<<c<<endl;
	}
	else if(a<=c&&c<=b){
	cout<<a<<" "<<c<<" "<<b<<endl;
	}
	else if(b<=a&&a<=c){
	cout<<b<<" "<<a<<" "<<c<<endl;
	}
	else if(b<=c&&c<=a){
	cout<<b<<" "<<c<<" "<<a<<endl;
	}
	else if(c<=a&&a<=b){
	cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else if(c<=b&&b<=a){
	cout<<c<<" "<<b<<" "<<a<<endl;
	}
	
return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
typedef long long ll;
const int inf=(1<<31)-1;
const double pi=acos(-1);

int a;
vi n(5);
char t;

int main(){
	while(cin>>a){
		vi vec,tmp;
		n[0]=a;
		vec.push_back(a);
		for(int i=1;i<5;i++){
			cin>>t>>n[i];
			bool used=1;
			for(int j=0;j<vec.size();j++){
				if(n[i]==vec[j]) used=0;
			}
			if(used) vec.push_back(n[i]);
			else tmp.push_back(n[i]);
		}
		if(vec.size()==4){
			cout<<"one pair"<<endl;;
			continue;
		}
		if(vec.size()==3){
			if(tmp[0]==tmp[1]) cout<<"three card"<<endl;
			else cout<<"two pair"<<endl;
			continue;
		}
		if(vec.size()==2){
			if(tmp[0]==tmp[1]&&tmp[1]==tmp[2]) cout<<"four card"<<endl;
			else cout<<"full house"<<endl;
			continue;
		}
		sort(n.begin(),n.end());
		int tmpn=0;
		for(int i=1;i<4;i++){
			if(n[i]+1==n[i+1]) tmpn++;
		}
		if((n[0]==1&&n[1]==10)||n[0]+1==n[1]) tmpn++;
		if(tmpn==4){
			cout<<"straight"<<endl;
			continue;
		}
		cout<<"null"<<endl;
	}
}

Measured memory_bytes: 1208
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){

  int r,g,b;
  cin>>r>>g>>b;
  cout<<((10*g+b)%4 ? "NO" : "YES");
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

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

const int64_t INF = 1LL << 60;


int main() {
    int N;
    cin >> N;
    int64_t h[100010];
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    
    int64_t dp[100010];
    for (int i = 0; i < 100010; ++i) {
        dp[i] = INF;
    }

    dp[0] = 0;

    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) {
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
    }
    
    cout << dp[N-1] << endl;

}


Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int n,i,x,y,z;
    cin>>n;
    int k=sqrt(n);
    int m[n+1]={0};
    for(x=1;x<=k;x++)
    {
        //int c=0;
        for(y=1;y<=k;y++)
        {
            for(z=1;z<=k;z++)
            {
                int a=x*x+y*y+z*z+x*y+y*z+z*x;
                if(a<=n)
                {
                    m[a]++;
                }
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        cout<<m[i]<<endl;
    }
    return 0;

}



Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
const int M  = 100005;
long long int N = 1e9 + 7;
long long int Z = 998244353;
/*int fac[M]={0};*/
//int dp[M]={0};
#define ll long long 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a%b); 
} 
// Use __gcd(int, int) as inbuilt function.
void precompute(){

}
int max3(int x, int y, int z){
    return max(x, max(y,z));
}
long long int power(long long int x, unsigned int y, int p) 
{ 
    long long int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
long long int modinv(long long int x, int p){
    return (power(x, p-2, p));
}
bool compare(const pair<int, int> &p1, const pair<int, int> &p2){
    return (p1.first> p2.first);
}
/*long long int nCrModP(long long int n, long long int r, long long int p) 
{ 
   if (r==0) 
      return 1;  
    return (fac[n] * modinv(fac[r], p) % p * modinv(fac[n-r], p) % p) % p; 
}*/

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t; cin>>t;
    cout<<((t/500)*1000 + ((t%500)/5) * 5);
   	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int a[5],k,d;

	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}

	cin >> k;

	d = a[4] - a[0];

	if (k >= d) {
		cout << "Yay!"<<endl;
	}
	else {
		cout << ":(" << endl;
	}

	return 0;


}

Measured memory_bytes: 256