akhauriyash/Code-Regression huggingface dataset:
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

long long int num[2000000];

int main(void){
    int n;
    cin >> n;
    long long int a[n];
    for(long long int i = 0;i < n;i++){
        cin >> a[i];
        num[a[i]]++;
    }
    
    long long int sum = 0;
    for(int i = 0;i <= n;i++){
        if(num[i] < 2)continue;
        long long int sum2 = (num[i]*(num[i]-1))/2;
        sum += sum2;
    }
    
    for(int i = 0;i < n;i++){
        long long int sum2 = num[a[i]]-1;
        cout << sum - sum2 << endl;
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) cin >> a[i];
    map<int, int> memo;
    for(int i = 1; i <= n; i++){
        if(memo.count(i-a[i])) memo[i-a[i]]++;
        else memo[i-a[i]] = 1;
    }

    long long int ans = 0;
    for(int i = 1; i <= n; i++){
        if(memo.count(i-a[i])){
            if(memo[i-a[i]] == 1) memo.erase(i-a[i]);
            else memo[i-a[i]]--;
        }
        if(memo.count(i+a[i])){
            ans += memo[i+a[i]];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12672
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  double a,b;
  cin >> a >> b;
  if(min(25/2.0*(a+1),10*(b+1))-max(25*a/2.0,10*b) >= 1){
	cout << (int)ceil(max(25*a/2.0,10*b)) << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
def is_wall(x1,y1,x2,y2):
    if x1<0 or 4<x1 or y1<0 or 4<y1 or x2<0 or 4<x2 or y2<0 or 4<y2:
        return False
    elif x1 == x2:
        if y1>y2: y1,y2 = y2,y1
        if y2-y1 != 1: return False
        return (walls[y1*2+1][x1] == "1")
    elif y1 == y2:
        if x1>x2: x1,x2 = x2,x1
        if x2-x1 != 1: return False
        return (walls[y1*2][x1] == "1")
    else: return False

def nextmove(x,y):
    lastmove = moves[-1]
    if lastmove == 3: lastmove = -1
    if lastmove < -1: lastmove += 4
    if is_wall(x,y,x+direction[lastmove+1][1],y+direction[lastmove+1][2]):
        return lastmove+1,x+direction[lastmove+1][1],y+direction[lastmove+1][2]

    if is_wall(x,y,x+direction[lastmove][1],y+direction[lastmove][2]):
        return lastmove,x+direction[lastmove][1],y+direction[lastmove][2]

    if is_wall(x,y,x+direction[lastmove-1][1],y+direction[lastmove-1][2]):
        return lastmove-1,x+direction[lastmove-1][1],y+direction[lastmove-1][2]

    if is_wall(x,y,x+direction[lastmove-2][1],y+direction[lastmove-2][2]):
        return lastmove-2,x+direction[lastmove-2][1],y+direction[lastmove-2][2]

direction = [["R",1,0],["U",0,-1],["L",-1,0],["D",0,1]]
walls = []
moves = [0]
for _ in range(9):
    walls.append(input())
lastx = 1
lasty = 0
print("R", end = "")
while True:
    move,lastx,lasty = nextmove(lastx, lasty)
    moves.append(move)
    print(direction[move][0], end = "")
    if lastx == 0 and lasty == 0: break
print()

Measured memory_bytes: 7484
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    cin >> n;
    ll pow10 = 1LL;
    ll pow8 = 1LL;
    ll pow9 = 1LL;
    rep(i, n) {
        pow10 = pow10 * 10LL % mod;
        pow9  = pow9  * 9LL % mod;
        pow8  = pow8  * 8LL % mod;
    }
    ll ans = pow10 - pow9;
    if (ans < 0) ans = ans + mod;
    ans = ans - pow9;
    if (ans < 0) ans = ans + mod;
    ans = (ans + pow8) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3504
using System;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        string[] input = ReadLine().Split(' ');
        string ans;
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        if (a % 2 == 0 || b % 2 == 0) { ans = "No"; }
        else { ans = "Yes"; }
        WriteLine(ans);
        
    }
}

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

int main()
{
	string N;

	cin >> N;

	if (N[0] == N[1] && N[1] == N[2])
		cout << "Yes" << endl;
	else if (N[1] == N[2] && N[2] == N[3])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var s     = spl[0];
        var t     = spl[1];
        spl       = input.ReadLine().Split(' ');
        var a     = int.Parse(spl[0]);
        var b     = int.Parse(spl[1]);
        var u     = input.ReadLine();

        if (u == s) {
            return (a-1) + " " + b;
        } else {
            return a + " " + (b-1);
        }
    }
}


Measured memory_bytes: 11092
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
ll dp[100001];
void solve()
{
	ll w;
	int n;
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
	{
		ll a, b;
		cin >> a >> b;
		for (int j = w - a; j >= 0; j--)
		{
			dp[j + a] = max(dp[j + a], b + dp[j]);
		}
	}
	cout << dp[w];
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

ll euclid(ll x, ll y, ll &k, ll &l) {
	if (y == 0) {
		k = 1;
		l = 0;
		return x;
	}
	ll g = euclid(y, x % y, l, k);
	l -= k * (x / y);
	return g;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	ll n;
	scanf("%lld", &n);
	ll ans = 2 * n;
	vector<ll> d;
	for (ll x = 2; x * x <= n; x++) {
		if (n % x) continue;
		ll y = 1;
		while(n % x == 0) {
			n /= x;
			y *= x;
		}
		d.push_back(y);
	}
	if (n > 1) d.push_back(n);
	bool ok = false;
	for (int i = 0; i < (int)d.size(); i++) {
		if (d[i] % 2 == 0) {
			d[i] *= 2;
			ok = true;
		}
	}
	if (!ok) d.push_back(2);

	int m = (int)d.size();
	assert(m < 18);
	for (int mask = 0; mask < (1 << m); mask++) {
		ll x = 1, y = 1;
		for (int i = 0; i < m; i++) {
			if ((mask >> i) & 1)
				x *= d[i];
			else
				y *= d[i];
		}
		if (y == 1) continue;
		ll k, l;
		euclid(x, y, k, l);
		//assert(euclid(x, y, k, l) == 1);
		l %= x;
		if (l <= 0) l += x;
		k = l * y - 1;
		ans = min(ans, k);	
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 3264
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b;
	c = (a + b) / 2;
	if ((a + b) % 2 == 1)cout << c + 1 << endl;
	else cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
a = 0
for i in range(len(x)):
    for j in range(i+1, len(x)):
        t = 0
        for k in range(d):
            t += (x[i][k]-x[j][k])**2
        if float.is_integer(t**0.5):
            a += 1
print(a)

Measured memory_bytes: 38384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

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

using namespace std;

#define int long long 

const int MOD = 998244353;

signed main(){
    int n;
    int a[400]={};
    
    cin >> n;

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

    int sum = 0;
    for(int i = 0; i < n; i++) sum += a[i];

    vector<int> dp(sum+1, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        vector<int> nx(sum+1, 0);
        for(int j = 0; j <= sum; j++){
            nx[j] += dp[j]*2%MOD;
            if(j + a[i] <= sum) nx[j + a[i]] += dp[j];
        }
        for(int j = 0; j <= sum; j++){
            dp[j] = nx[j] % MOD;
        }
    }
    
    vector<int> dp2(sum+1, 0);
    dp2[0] = 1;
    for(int i = 0; i < n; i++){
        vector<int> nx(sum+1, 0);
        for(int j = 0; j <= sum; j++){
            nx[j] += dp2[j];
            if(j + a[i] <= sum) nx[j + a[i]] += dp2[j];
        }
        for(int j = 0; j <= sum; j++){
            dp2[j] = nx[j] % MOD;
        }
    }

    int ans = 0;
    if(sum % 2 == 0){
        ans -= dp2[sum/2]*3%MOD;
        ans += MOD;
    }

    for(int j = (sum+1)/2; j <= sum; j++){
        ans += dp[j]*3;
        ans %= MOD;
    }
    ans = MOD - ans;

    int po3 = 1;
    for(int i = 0; i < n; i++) po3 = po3*3%MOD;
    ans += po3;
    ans %= MOD;

    cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	int n,k;
	int[]a;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		k=sc.nextInt();
		a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		
		//二分探索
		int ans=-1;
		int max=n;
		int min=0;
		int i=0;
		LOOP:while(min<max){
			i=(max+min)/2;
			
			if(a[i]>k){
				max=i;
				continue;
			}
			int idx=0;
			
			//dp[j][sum]:=j枚目までで和sumを作れるか
			boolean[][]dp=new boolean[n][k];
			for(int j=0;j<n;j++){
				dp[j][0]=true;
			}
			
			for(int j=1;j<n;j++){
				if(idx==i)idx++;	//i枚目は使わないので
				
				for(int sum=0;sum<k;sum++){
					if(dp[j-1][sum]){
						dp[j][sum]=true;
						int temp=sum+a[idx];
						if(temp<k)dp[j][temp]=true;
					}
				}
				idx++;
			}
			
			for(int sum=k-a[i];sum<k;sum++){
				if(dp[n-1][sum]){
					max=i;
					continue LOOP;
				}
			}
			ans=i;
			min=i+1;
		}
		System.out.println(ans+1);
	}
}


Measured memory_bytes: 206048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;
  bool z = true;
  rep(i, sz(s) - 1){
    if(s[i]!=s[i+1]){
      z = false;
    }
  }
  if(z){
    print(k * sz(s) / 2);
    return 0;
  }
  string ss = s + s;
  string sss = s + s + s;
  string ssss = s + s + s + s;
  string sssss = s + s + s + s + s;
  ll n = 0, m = 0, o = 0, u = 0, a = 0;
  for (ll i = 1; i < sz(s); i++){
    if(s[i]==s[i-1]){
      s[i] = '*';
      n++;
    }
  }
  for (ll i = 1; i < sz(ss);i++){
    if(ss[i]==ss[i-1]){
      ss[i] = '*';
      m++;
    }
  }
  for (ll i = 1; i < sz(sss);i++){
    if(sss[i]==sss[i-1]){
      sss[i] = '*';
      o++;
    }
  }
  for (ll i = 1; i < sz(ssss);i++){
    if(ssss[i]==ssss[i-1]){
      ssss[i] = '*';
      u++;
    }
  }
  for (ll i = 1; i < sz(sssss);i++){
    if(sssss[i]==sssss[i-1]){
      sssss[i] = '*';
      a++;
    }
  }
  ll l = m - n;
  ll p = o - m;
  ll q = u - o;
  ll b = a - u;
  ll ans;
  if(k==1){
    ans = n;
  }
  else if(k==2){
    ans = m;
  }
  else if(k==3){
    ans = o;
  }
  else if(k==4){
    ans = a;
  }
  else{
    ans = a + b * (k - 5);
  }
  print(ans);
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define plll pair<ll, pll>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	vector<ll> line(n);
	ll ans = 0;
	priority_queue<ll> pq;
	foreach(i, line){
		cin >> i;
		pq.push(i);
	}
	while(true){
		bool flag = false;
		foreach(j, line){
			ll add = max(0ll, (j+ans)/n);
			if(add){
				flag = true;
				j -= add * (n+1);
				ans += add;
			}
		}
		if(!flag)break;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,l,r) for(ll i=l;i<=r;i++)
#define fe(i,u) for(ll i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
const ll N=100010;
struct edge{ ll v,ty,next; edge(ll v=0,ll ty=0,ll next=0):v(v),ty(ty),next(next){} }e[N<<1];
ll n,m,col[N],cnt[3],siz; ll tot=0,head[N];
bool flag;
inline void add(ll u,ll v,ll ty){e[++tot]=edge(v,ty,head[u]);head[u]=tot;}
void dfs(ll u) { cnt[col[u]]++; fe(i,u){ ll v=e[i].v,ty=e[i].ty; siz+=(ty==1); if(~col[v])flag|=(col[v]!=(col[u]+ty)%3); else col[v]=(col[u]+ty)%3,dfs(v); } }
int main() {
	scanf("%lld%lld",&n,&m); fo(i,1,m){ ll x,y; scanf("%lld%lld",&x,&y); add(x,y,1);add(y,x,2); }
    memset(col,-1,sizeof col); ll ans=0;
    fo(i,1,n){
        if(~col[i])continue; cnt[col[i]=0]=cnt[1]=cnt[2]=siz=flag=0; dfs(i);
        if(flag)ans+=(cnt[0]+cnt[1]+cnt[2])*(cnt[0]+cnt[1]+cnt[2]); else if(cnt[0]&&cnt[1]&&cnt[2])ans+=cnt[0]*cnt[1]+cnt[1]*cnt[2]+cnt[2]*cnt[0]; else ans+=siz;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,ans,x;
int main() {
	scanf("%d%d",&n,&k);
	for (int i=1; i<=n; i++) {
		scanf("%d",&x);
		if(x<=k/2) {
			ans+=x*2;
		} else {
			ans+=(k-x)*2;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int board[1000],dice[1000];

int main()
{
	int n,m;
	while(cin>>n>>m,n)
	{
		rep(i,n)cin>>board[i];
		rep(i,m)cin>>dice[i];
		int cur=0,ans=0;
		while(cur<n-1)
		{
			cur+=dice[ans];
			cur+=board[cur];
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;


vector<int64_t> solve(int n, int m, int64_t s, const vector<vector<tuple<int, int, int64_t> > > & g, const vector<int64_t> & c, const vector<int64_t> & d) {
    int sum_a = 0;
    REP (x, n) {
        for (auto [y, a, b] : g[x]) if (x < y) {
            sum_a += a;
        }
    }

    vector<vector<int64_t> > dist(n, vector<int64_t>(sum_a + 1, INT64_MAX));
    reversed_priority_queue<tuple<int64_t, int, int> > que;
    auto push = [&](int x, int j, int64_t dist_x_j) {
        if (j < 0) return;
        j = min(sum_a, j);
        if (dist_x_j < dist[x][j]) {
            dist[x][j] = dist_x_j;
            que.emplace(dist_x_j, x, j);
        }
    };
    push(0, s, 0);
    while (not que.empty()) {
        auto [dist_x_j, x, j] = que.top();
        que.pop();
        if (dist_x_j > dist[x][j]) continue;
        push(x, j + c[x], dist_x_j + d[x]);
        for (auto [y, a, b] : g[x]) {
            push(y, j - a, dist_x_j + b);
        }
    }

    vector<int64_t> ans(n - 1, INT64_MAX);
    REP (x, n - 1) {
        REP (j, sum_a + 1) {
            ans[x] = min(ans[x], dist[x + 1][j]);
        }
    }
    return ans;
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t N, M, S;
    cin >> N >> M >> S;
    vector<vector<tuple<int, int, int64_t> > > g(N);
    REP (i, M) {
        int u, v, a; int64_t b;
        cin >> u >> v >> a >> b;
        -- u;
        -- v;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }
    vector<int64_t> C(N), D(N);
    REP (i, N) {
        cin >> C[i] >> D[i];
    }
    auto ans = solve(N, M, S, g, C, D);
    REP (i, N - 1) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6388
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    char c;
    cin >> c;
    std::string s = "aeiou";
    for (int i = 0; i < 5; i++) {
        if (c == s[i]) {
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;

    return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int l, cnt= 0;
    string s;
    cin>> l >>s;

    for (int i= 0; i<l-2; i++)
    {
        if(s[i]=='A' && s[i+1]== s[i] +1 && s[i+2]== s[i] +2  )
            cnt++;
    }

    cout << cnt;
    nl;


    return 0;
}




Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;
const int mod = 1e9 + 7;
const double EPS = 1e-9;


struct team{
	int id, shozoku, ac, pena;
	team(){};
	team(int id, int shozoku, int ac, int pena) : id(id), shozoku(shozoku), ac(ac), pena(pena){};
	bool operator <(const team &t) const{
		if(ac != t.ac) return ac > t.ac;
		if(pena != t.pena) return pena < t.pena;
		return id < t.id;
	}
};


int main(){
	int n;
	while(cin>>n && n > 0){
		vector<team> v(n);
		int a, b, c, d;
		for(int i = 0; i < n; i++){
			cin>>a>>b>>c>>d;
			v[i] = team(a, b, c, d);
		}
		sort(all(v));

		int win = 0;
		vi vwin(10000, 0);

		for(int i = 0; i < n; i++){
			if(win < 10 && vwin[v[i].shozoku] < 3){
				cout<<v[i].id<<endl;
				win++;
				vwin[v[i].shozoku]++;
			}else if(win < 20 && vwin[v[i].shozoku] < 2){
				cout<<v[i].id<<endl;
				win++;
				vwin[v[i].shozoku]++;
			}else if(win < 26 && vwin[v[i].shozoku] == 0){
				cout<<v[i].id<<endl;
				win++;
				vwin[v[i].shozoku]++;
			}
			if(win >= 26){
				break;
			}
		}	
	}
}	

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

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    p.at(i) = make_pair(a,i);
  }
  sort(p.begin(),p.end());
  for(int j=0;j<n;j++){
    int a,b;
    tie(a,b) = p.at(j);
    cout << b+1 << " " ;
  }
}

Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <array>

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

int main() {

  int N;
  std::cin >> N;
  std::vector<std::array<int, 3>> a(N);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < 3; ++j)
      std::cin >> a[i][j];

  int inf = 1000000007;
  std::vector<std::array<int, 3>> dp(N + 7, {-inf, -inf, -inf});

  for (int j = 0; j < 3; ++j)
    dp[0][j] = 0;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      chmax(dp[i + 1][(j + 1) % 3], dp[i][j] + a[i][(j + 1) % 3]);
      chmax(dp[i + 1][(j + 2) % 3], dp[i][j] + a[i][(j + 2) % 3]);
    }
  }

  int res = -inf;
  for (int j = 0; j < 3; ++j)
    chmax(res, dp[N][j]);
  std::cout << res << std::endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;

int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

string alpha="abcdefghijklmnopqrstuvwxyz";

string s;



int main(){
	cin>>s;
	cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
    int s_length, t_length, consist_char_num = 0, answer = 0;

    char s[1000];
    char t[1000];

    scanf("%s", s);
    scanf("%s", t);

    s_length = strlen(s);
    t_length = strlen(t);

    for (int i = 0; i<(s_length - t_length + 1); i++)
    {
        int current_consist_char_num = 0;

        for (int j = 0; j<t_length; j++)
        {
            if (s[i+j] == t[j])
            {
                current_consist_char_num ++;
            }
        }

        if (current_consist_char_num > consist_char_num)
        {
            consist_char_num = current_consist_char_num;
        }
    }

    answer = t_length - consist_char_num;


    printf("%d", answer);

    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#include <cmath>

using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);++(i))

i64 w;
i64 h;

int main()
{
	cin >> w >> h;
	vector<P> vec;
	rep(i,1,w)
	{
		i64 p;
		cin >> p;
		vec.push_back({p,0});
	}
	rep(i,1,h)
	{
		i64 p;
		cin >> p;
		vec.push_back({p,1});
	}
	sort(vec.begin(),vec.end());
	i64 cou[2] = {h +  1,w + 1};
	i64 result = 0;
	for(P & p : vec)
	{
		if(cou[0] == 0 && cou[1] == 0) break;
		result += cou[p.second] * p.first;
		cou[1 - p.second]--;
	}
	cout << result << endl;
}





Measured memory_bytes: 6512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define SG getchar()
#define P putchar
using namespace std;
string s;
stack<char> uh;
signed main()
{
	char c;
	while((c=SG)!=10)
	{
		switch(c)
		{
			case (48):uh.push(c);break;
			case (49):uh.push(c);break;
			case 66:if(!uh.empty()){uh.pop();}break;
		}
	}
	while(!uh.empty()){s+=(uh.top()),uh.pop();}
	reverse(s.begin(),s.end());cout<<s;
	return putchar(10),0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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


	long long n, i, j, k, ans, s;
	cin >> n;
	vector<long long> a(n * 3), x(n * 3, -1LL << 57), y(n * 3, 1LL << 57);
	for (i = 0; i < n * 3; i++) cin >> a[i];
	s = 0;
	priority_queue<long long> q, qq;
	for (i = 0; i < n; i++) {
		q.push(-a[i]);
		s += a[i];
	}
	x[n - 1] = s;
	for (i = n; i <= 2 * n - 1; i++) {
		q.push(-a[i]);
		s += a[i];
		s += q.top();
		q.pop();
		x[i] = s;
	}

	s = 0;
	for (i = 3 * n - 1; i >= 2 * n; i--) {
		qq.push(a[i]);
		s += a[i];
	}
	y[2 * n] = s;
	for (i = 2 * n - 1; i >= n; i--) {
		qq.push(a[i]);
		s += a[i];
		s -= qq.top();
		qq.pop();
		y[i] = s;
	}

	ans = -1LL<<60;
	for (i = n - 1; i < 2 * n; i++) ans = max(ans, x[i] - y[i + 1]);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 9588
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int n,m,q,max=0;
int A[11]={1};
int a[50],b[50],c[50],d[50];

void score(void)
{
  int i;
  int tmp=0;
  for(i=0;i<q;i++)
  {
    if(A[b[i]]-A[a[i]]==c[i]) tmp+=d[i];
  }
  if(max<tmp) max=tmp;
}

void loop(int i)
{
  int j;
  for(j=A[i-1];j<=m;j++)
  {
    A[i]=j;
    if(i==n) score();
    else loop(i+1);
  }
}

int main(void)
{
  int i;
  scanf("%d %d %d",&n,&m,&q);
  for(i=0;i<q;i++)
  {
    scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
  }

  loop(1);

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

  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <cmath>
#include <string>

using namespace std;

int main(void) {
    int n[3];
    int ret = 0;
    cin >> n[0] >> n[1] >> n[2];
    int odd = (n[0] % 2) + (n[1] % 2) + (n[2] % 2);
    if(odd == 1) {
        ret++;
        for(int i = 0;i<3;i++) {
            if(n[i] % 2 == 0)
                n[i]++;
        }
    }
    if(odd == 2) {
        ret++;
        for(int i = 0;i<3;i++) {
            if(n[i] % 2 == 1)
                n[i]++;
        }
    }
    int m = max(max(n[0],n[1]),n[2]);
    for(int i = 0;i < 3;i++) {
        ret = ret + (m - n[i]) / 2;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

int main(void)
{
  int i,n,a[10001],q,key,ans;
  ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(linearSearch(a,n,key)){
      ans++;
    }
  }
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n,x,y,z;
    LL ans;
    map<deque<int>,LL> m[41];
    Problem(LL n):n(n),ans(0){};
    long long modpow(long long a, long long n,long long mod=MOD){
        long long i=1,ret=1,p=a;
        while(i<=n){
            if(i&n) ret=(ret*p)%mod;
            i=(i<<1);
            p=(p*p)%mod;
        }
        return ret;
    }
    void solve(){
        cin >> x >> y >> z;
        m[0][{}]=1;
        for(int i=0; i<n; ++i){
            for(auto && v:m[i]){
                deque<int> w;
                for(int j=1; j<=10; ++j){
                    bool haiku=false;
                    w=v.first;
                    for(int k=0; k<(int)w.size(); ++k){
                        if(w[k]!=0){
                            if((w[k]<x and w[k]+j>x) or (w[k]<x+y and w[k]+j>x+y) or(w[k]<x+y+z and w[k]+j>x+y+z)){
                                w[k]=0;
                            }else{
                                w[k]+=j;
                            }
                        }
                        if(w[k]==x+y+z)haiku=true;
                    }
                    if(haiku){
                        //DBG(w,v.first,v.second)
                        ans+=v.second*modpow(10,n-1-i);
                        ans%=MOD;
                    }else{
                        w.push_back(j<=x?j:0);
                        while(!w.empty() and w[0]==0)w.pop_front();
                        m[i+1][w]+=v.second;
                        m[i+1][w]%=MOD;
                    }
                }
            }
            DBG(ans)
        }
        cout << ans <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 246400
a, b = gets.split.map(&:to_i)

t = [1]
(2..999).each do |i|
  t[i - 1] = t[i - 2] + i
end

(0..t.size-1).each do |i|
  if t[i + 1] - t[i] == b - a
    puts t[i] - a
    exit
  end
end 



Measured memory_bytes: 1788
MOD = 1000000007
MAX = 10**6  # max n

fac = [0 for _ in range(MAX)]  # = n! (mod MOD)
finv = [0 for _ in range(MAX)]  # = 1/r! (mod MOD)
inv = [0 for _ in range(MAX)]  # = 1/r (mod MOD)


# init
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


# nCk, n < [0, MAX), k < [0, n]
def COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

def main():
    # input
    x, y = map(int, input().split())
    if (x+y)%3 == 0:
        num = (x+y)//3
        for i in range(num+1):
            if x==2*y:
                move = i
                break
            x-=1
            y-=2
        else:
            print(0)
            return
    else:
        print(0)
        return

    # calc
    COMinit()
    print(COM(num, move))


if __name__ == '__main__':
    main()


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

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

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

int main() {
    ll A,B;
    cin >> A >> B;
    cout << lcm(A,B) << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,n;cin >> h >> w >> n;
    int sh,sw;cin >> sh >> sw;
    sh--,sw--;
    string s,t;cin >> s >> t;
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
    int l=0,r=w-1,u=0,d=h-1;
    if(s[0]=='L'){
        l++;
    }
    if(s[0]=='R'){
        r--;
    }
    if(s[0]=='U'){
        u++;
    }
    if(s[0]=='D'){
        d--;
    }
    for(int i=1;i<n;i++){
        if(t[i]=='L'){
            r=min(w-1,r+1);
        }
        if(t[i]=='R'){
            l=max(0,l-1);
        }
        if(t[i]=='U'){
            d=min(h-1,d+1);
        }
        if(t[i]=='D'){
            u=max(0,u-1);
        }
        if(s[i]=='L'){
            l++;
        }
        if(s[i]=='R'){
            r--;
        }
        if(s[i]=='U'){
            u++;
        }
        if(s[i]=='D'){
            d--;
        }
        if(l>r||u>d){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(l<=sw&&sw<=r&&u<=sh&&sh<=d){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 920
#include <cstdio>

const int N_MAX = 200000;
int N, K;
int A[N_MAX];

void up_heap(int arr[], int i)
{
    int j = (i - 1) / 2;
    int tmp = arr[i];
    if (i == 0) return;
    if (arr[i] <= arr[j]) return;
    arr[i] = arr[j];
    arr[j] = tmp;
    up_heap(arr, j);
}

void down_heap(int arr[], int i)
{
    int j = 0, k = j * 2 + 1;
    int tmp = arr[0];
    arr[0] = arr[i];
    arr[i] = tmp;
    while(k <= i - 1) {
        k = j * 2 + 1;
        if (k + 1 <= i - 1)
            k = arr[k] >= arr[k + 1] ? k : k + 1;
        if (arr[j] >= arr[k]) return;
        tmp = arr[j];
        arr[j] = arr[k];
        arr[k] = tmp;
        j = k;
        k = j * 2 + 1;
    }
}

void sort(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        up_heap(arr, i);
    for (int i = n - 1; i >= 0; i--)
        down_heap(arr, i);
}

int main()
{
    int num[N_MAX];
    int sum = 0;
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        A[i]--;
        num[i] = 0;
    }
    for (int i = 0; i < N; i++)
        num[A[i]]++;
    sort(num, N);
    for (int k = 0; k < K; k++)
        sum += num[N - k - 1];
    printf("%d\n", N - sum);
    
    
    return 0;
}


Measured memory_bytes: 1664
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int w, h, n;
    cin >> w >> h >> n;

    int x_0 = 0, y_0 = 0, x_1 = w, y_1 = h;
    int x, y, a;
    REP(i, n){
        cin >> x >> y >> a;
        if(a == 1){
            if(x_0 < x) x_0 = x;
        }else if(a == 2){
            if(x < x_1) x_1 = x;
        }else if(a == 3){
            if(y_0 < y) y_0 = y;
        }else if(a == 4){
            if(y < y_1) y_1 = y;
        }
    }
    if(x_1 > x_0 and y_1 > y_0){
        cout << max(0, ((x_1 - x_0) * (y_1 - y_0))) << endl;
    }else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int main() {
  while (true) {
    int e;
    cin >> e;
    if (e == 0) break;
    int res = e;
    for (int z = 0; z * z * z <= e; ++z) {
      int ee = e - z * z * z;
      for (int y = 0; y * y <= ee; ++y) {
	int eee = ee - y * y;
	res = min(eee + y + z, res);
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

int main(){
	int A,B,C,D;
	cin >> A >> B;
	C=0;
	D=0;

	for(int i =A;i<B+1;i++){
		int k = i;
		for(int j =5;j>0;j--){
			D=D + pow(10,j-1)*(k%10);
			k = k/10;
		}
		if(D==i){
			C++;
		}
		k=0;
		D=0;
	
	}
	cout << C << endl;
}

Measured memory_bytes: 384
n,m = map(int,input().split())
ab_ls = [list(map(int,input().split())) for i in range(n)]
ab_ls.sort(key=lambda x: x[0])
ans = 0
temp_m = 0
for i in range(n):
    if temp_m == m:
        break
    if m-temp_m >= ab_ls[i][1]:
        ans += ab_ls[i][0] * ab_ls[i][1]
        temp_m += ab_ls[i][1]
    elif m-temp_m < ab_ls[i][1]:
        ans += ab_ls[i][0] * (m-temp_m)
        break
     


print(ans)

Measured memory_bytes: 29024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	K := nextInt()

	S := make([]int, N)

	for i := 0; i < K; i++ {
		d := nextInt()
		for j := 0; j < d; j++ {
			a := nextInt() - 1
			S[a]++
		}
	}
	c := 0
	for i := 0; i < N; i++ {
		if S[i] == 0 {
			c++
		}
	}

	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1828
#include<stdio.h>

void trace(int A[],int N)
{
  for(int i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}


int selectionSort(int A[],int N){
  int sw=0;
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j]<A[minj]) minj=j;
	int t=A[j];
	
    }
    if(i!=minj){
    int t=A[i];
    A[i]=A[minj];
    A[minj]=t;
    sw++;
    }
  }
    
  trace(A,N);
  return sw;
}

int main(void)
{
  int N;
  int A[100];
  int sw;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  sw=selectionSort(A,N);
  printf("%d\n",sw);
  return 0;
}



Measured memory_bytes: 2068
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A, B;
    cin >> A >> B;
    if (B % A == 0)
        cout << A + B;
    else
        cout << B - A;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

i = 10
call = []
try:
    for j in range(i):
        n = input()
        if (n == ''):
            break

        call.append(int(n))
except EOFError:
    pass

bingo = []

bingo.append(a)
bingo.append(b)
bingo.append(c)
bingo.append([a[0], b[0], c[0]])
bingo.append([a[1], b[1], c[1]])
bingo.append([a[2], b[2], c[2]])
bingo.append([a[0], b[1], c[2]])
bingo.append([a[2], b[1], c[0]])

ans = True
test = []
for ls in bingo:
    for num in ls:
        ans = ans and (num in call)

    if ans == True:
        print('Yes')
        exit(0)

    ans = True

print('No')

Measured memory_bytes: 3064
import Control.Applicative
import Data.List

main = do
    n <- readLn
    print $ solve n

solve :: Int -> Int
solve n = minimum $ map (f n) [1..(1 + div n 2)]

f :: Int -> Int -> Int
f n a = g (show a) + g (show b)
    where b = n - a

g :: String -> Int
g digStr = sum $ map (read . (\chr->[chr])) digStr

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()




void solve(){
  int k, n; cin >> k >> n;
  vector<int> a(n);
  FOR(i,0,n) cin >> a[i];
  int ans=k+5;
  FOR(i,0,n-1) ans = min(ans,k - abs(a[(i+1)%n]-a[i]));
  ans = min(ans, a[n-1] - a[0]);
  cout << ans;
}

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

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

using namespace std;

vector<int> adj[100007];
int in[100007] = {};
int dp[100007] = {};

int main() {
	
	int i,j;
	int N,M;
	
	scanf("%d %d", &N, &M);
	for( i=1; i<=M; i++) {
		int x,y;
		scanf("%d %d", &x, &y);
		adj[x].push_back(y);
		in[y]++;
	}
	
	queue<int> que;
	for( i=1; i<=N; i++) {
		if( in[i] == 0)
			que.push(i);
	}
	while( !que.empty()) {
		int x = que.front();
		que.pop();
		for( auto y:adj[x]) {
			if( --in[y] == 0)
				que.push(y);
			dp[y] = max( dp[y], dp[x]+1);
		}
	}
	int ans = 0;
	for( i=1; i<=N; i++)
		ans = max( ans, dp[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10004
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int x, y;
  cin >> x >> y;

  int ans = 0;
  if (x == 1) ans += 300000;
  else if (x == 2) ans += 200000;
  else if (x == 3) ans += 100000;

  if (y == 1) ans += 300000;
  else if (y == 2) ans += 200000;
  else if (y == 3) ans += 100000;

  if (x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
  return 0;
}

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

int main()
{
	
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a&&c<=b)
	{
		cout<<"Yes"<<endl; 
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

#define R register
int a[60], b[60], c[60], d[60];
int main()
{
	R int n, m; scanf("%d%d", &n, &m);
	for (R int i = 1; i <= n; ++i) scanf("%d%d", &a[i], &b[i]);
	for (R int i = 1; i <= m; ++i) scanf("%d%d", &c[i], &d[i]);
	for (R int i = 1; i <= n; ++i)
	{
		R int maxx = 0x7fffffff, ans = 0;
		for (R int j = 1; j <= m; ++j)
			if (std::abs(a[i] - c[j]) + std::abs(b[i] - d[j]) < maxx) ans = j, maxx = std::abs(a[i] - c[j]) + std::abs(b[i] - d[j]);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

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(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll a(N);
    for(ll i=0;i<N;i++)cin>>a[i];
    
    vll count(100001,0);
    for(ll i=0;i<N;i++){
        count[a[i]]++;
    }
    
    ll ans=0;
    for(ll i=1;i<100000;i++){
        chmax(ans,count[i]+count[i+1]+count[i-1]);
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int asc(const void* a, const void* b) {
    return *(int*)b - *(int*)a;
}
int main() {
    int x,flag=0;
    scanf("%d", &x);
   
    if (x == 2) printf("%d", x);
    else if (x == 3)printf("%d", x);
    else {
        for (int i = x;; i++) {
            //printf("%d\n", i);

            if (i % 2) {
                for (int j = 3;; j += 2) {
                    //printf("j=%d\n", j);
                    if(j >= i - 1) {
                        flag = 1;
                         break;
                    }
                    else if (i % j == 0)break;
                    
                }
            }
            if (flag) {
                printf("%d", i);
                break;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 128
n = gets.to_i
ary = []
ns = ['7','5','3']
(3..9).each do |i|
  nums = ns.repeated_permutation(i).select{ |set| (ns - set).empty? }.map(&:join)
  ary += nums
end
 
 
cnt = ary.select{|num| num.to_i <= n}
puts cnt.length

Measured memory_bytes: 9852
#include <algorithm>
#include <complex>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int d, n;
  cin >> d >> n;
  int l[] = {1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17,
             18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
             35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
             52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
             69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
             86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101};
  switch (d) {
  case 0: {
    cout << l[n - 1] << endl;
    break;
  }
  case 1: {
    cout << l[n - 1] * 100 << endl;
    break;
  }
  case 2: {
    cout << l[n - 1] * 100 * 100 << endl;
    break;
  }
  }
  return 0;
}


Measured memory_bytes: 256