akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, p[111111];

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> p[i];

    p[i] --;
  }

  p[N] = INF;

  int c = 0;

  for (int i = 0; i < N; i ++)
    if (p[i] == i) {
      std::swap(p[i], p[i + 1]);

      c ++;
    }

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
UV = [[int(x) for x in row.split()] for row in sys.stdin.readlines()]

graph = [[] for _ in range(N+1)]
for u,v in UV:
    graph[u].append(v)
    graph[v].append(u)

color = [None] * (N+1)

def calc_comp_data(v):
    c = 0
    q = [v]
    color[v] = 0
    is_bipartite = True
    size = 1
    while q:
        qq = []
        c ^= 1
        for x in q:
            for y in graph[x]:
                if color[y] is None:
                    color[y] = c
                    qq.append(y)
                    size += 1
                elif color[y] == c:
                    continue
                else:
                    is_bipartite = False
        q = qq
    return size,is_bipartite

size = []
is_bipartite = []
for v in range(1,N+1):
    if color[v] is not None:
        continue
    x,y = calc_comp_data(v)
    size.append(x)
    is_bipartite.append(y)

size,is_bipartite

n_point = sum(1 if s == 1 else 0 for s in size)
n_component = len(size)
n_bipartitle = sum(1 if s >= 2 and bl else 0 for s,bl in zip(size,is_bipartite))

answer = 0
for s,bl in zip(size,is_bipartite):
    if s == 1:
        # 第1成分が1点のとき
        answer += N
    elif not bl:
        # 第1成分が2点以上、非二部グラフ
        # 成分の個数が足される
        answer += (n_component - n_point) + s*n_point
    else:
        # 第1成分が2点以上の二部グラフ
        # 相手が2点以上の二部グラフなら、2つできる
        answer += (n_component - n_point) + n_bipartitle + s*n_point

print(answer)

Measured memory_bytes: 54416
import java.util.Scanner;
public class Main {
	static int[][] gyo2=new int[100000][12];
	static int count=0;
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String S=sc.next();
		String T=sc.next();
		String[] s=S.split("");
		String[] t=T.split("");
		for(int i=0;i<s.length;i++) {
			if(!s[i].equals(t[i])) {
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");

}

}


Measured memory_bytes: 42348
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll X; cin >> X;
    ll C = 100, y;
    for(y=1; ; ) {
        C += C / 100;
        if(C >= X) break;
        y++;
    }
    cout << y << endl;
    return 0;
}


Measured memory_bytes: 3624
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def fact(n):
        if n < 4:
            return set([n])
        i = 2
        res = set([n])
        while i ** 2<= n:
            if n%i == 0:
                res.add(i)
                m = n//i
                if m != i:
                    res.add(m)
            i += 1
        return res

    def check(n,i):
        while n >= i:
            if n%i == 0:
                n //= i
            else:
                n -= i
        if n == 1:
            return 1
        return 0
    n = I()
    if n == 2:
        print(1)
        return
    ans = {2,n}
    f = fact(n)
    for i in f:
        m = n
        while not m%i:
            m //= i
        if m % i == 1:
            ans.add(i)
    ans |= fact(n-1)
    print(len(ans))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 40304
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

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

const int N=10;

int n,m; char s[N][N];

void GG() { puts("Impossible"); exit(0); }

int main() {
	n=read(),m=read();
	for (int i=1;i<=n;++i) scanf("%s",s[i]+1);
	for (int i=1;i<n;++i)
		for (int j=1;j<m;++j) {
			if (s[i][j]=='#'&&s[i][j+1]=='#'&&s[i+1][j]=='#') GG();
			if (s[i][j+1]=='#'&&s[i+1][j]=='#'&&s[i+1][j+1]=='#') GG();
		}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int A;

	cin >> A;

	int B;
	cin >> B;
	int C;
	cin >> C;

	if (A-B)
	{
		if (B == C) {

			cout << A << endl;
		}
		else {

			cout << B << endl;
		}
	}
	else {

		cout << C << endl;
	}

	return 0;
}

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

using ll = long long;

const int maxn = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int tc = 1;
    // cin >> tc;
    while(tc--) {
        int n, q;
        cin >> n;
        vector<ll> a(maxn, 0);
        ll sum = 0;
        for(int i=0; i<n; i++) {
            int num;
            cin >> num;
            a[num]++;
            sum += num;
        }
        
        cin >> q;
        while(q--) {
            ll b, c;
            cin >> b >> c;
            sum += (c - b) * a[b];
            a[c] += a[b];
            a[b] = 0;
            cout << sum << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3988
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigInteger N = new BigInteger(sc.next());
		BigInteger A = new BigInteger(sc.next());
		BigInteger B = new BigInteger(sc.next());

		BigInteger sum = A.add(B);
		BigInteger setCount = N.divide(sum);
		BigInteger remain = N.remainder(sum);

		BigInteger result = A.multiply(setCount);
		if (remain.compareTo(A) >= 0) {
			result = result.add(A);
		} else {
			result = result.add(remain);
		}

		System.out.println(result);

		sc.close();
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n){
    cin >> h.at(i);
  }
  string ans="Yes";
  ll maxi=0;
  rep(i,n){
    maxi=max(maxi,h.at(i));
    if(maxi>h.at(i)+1){
      ans="No";
    }
  }
  cout << ans;
}
    
    

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

using namespace std;

typedef long long ll;

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

int kyu(int x){
	if(x <= 599) return 8;
	if(x <= 799) return 7;
	if(x <= 999) return 6;
	if(x <= 1199) return 5;
	if(x <= 1399) return 4;
	if(x <= 1599) return 3;
	if(x <= 1799) return 2;
	if(x <= 1999) return 1;
}

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

	int x;
	cin >> x;
	cout << kyu(x) << endl;

}


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

long long L[100];

int main(){

  int N; cin >> N;
  
  L[0] = 2;
  L[1] = 1;
  
  for(int i = 0; i < N; i++){
    L[i+2] = L[i+1] + L[i];
  }
  
  cout << L[N] << endl;
}



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

int main()
{
    int a,b;
    cin >> a >> b;
    if (a < b) {
        for (int i = 0; i < b; i++)
            cout << a;
        cout << '\n';
    } else if (b <= a) {
        for (int i = 0; i < a; i++)
            cout << b;
        cout << '\n';
    }
        
    return 0;
}

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

int main()
{
	long num, i,dif;
	cin >> num;
	num *= 3;
	int a[num];
	for (i = 0; i < num; i++) cin >> a[i];
	sort(a, a + num, greater<int>());
	dif = 0;
	/*for (i = 0; i < num*2/3; i++) {
		if (i % 2 == 1) dif += a[i];
	}*/
	num /= 3;
	for (i = 0; i < num; i++) {
		dif += a[2 * i + 1];
	}
	cout << dif;
	return 0;
}


Measured memory_bytes: 1408
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll D, N;

int main() {
	scanf("%lld %lld", &D, &N);
	if(D == 0) {
		if(N != 100) {
			printf("%lld\n", N);
		}
		else {
			printf("101\n");
		}
	}
	else if(D == 1) {
		if(N != 100) {
			printf("%lld\n", N * 100);
		}
		else {
			printf("10100\n");
		}
	}
	else {
		if(N != 100) {
			printf("%lld\n", N * 10000);
		}
		else {
			printf("1010000\n");
		}
	}

	return 0; 
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int64_t MAXN = 100010;
vector<vector<pair<int64_t, int64_t>>> Graph(MAXN);
vector<int64_t> Color(MAXN, -1);

void dfs(int64_t cur, bool color)
{
  Color.at(cur) = color;
  for (int64_t i = 0; i < Graph.at(cur).size(); i++)
  {
    int64_t nxt_i, w;
    tie(nxt_i, w) = Graph.at(cur).at(i);
    if (Color.at(nxt_i) != -1)
      continue;
    bool nxt_color = (w % 2 == 1) ? !color : color;
    Color.at(nxt_i) = nxt_color;
    dfs(nxt_i, nxt_color);
  }
}

int main()
{
  int64_t N, u, v, w;
  cin >> N;
  for (int i = 0; i < N - 1; i++)
  {
    cin >> u >> v >> w;
    Graph.at(u).push_back(make_pair(v, w));
    Graph.at(v).push_back(make_pair(u, w));
  }
  dfs(1, 1);
  for (int i = 1; i <= N; i++)
  {
    cout << Color.at(i) << endl;
  }
}

Measured memory_bytes: 11776
#include<iostream>
using namespace std;
int main(){
	string S;
	int ans=0,i;
	cin >> S ;
	for(i=0;i<S.size()/2;i++){
		if(S[i]!=S[S.size()-i-1]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;cin>>n>>m;
	int ans = 0;
	for(int i = 0; i < m; i++) {
		int x;cin>>x;
		ans += x;
	}
	if (n - ans >= 0){
		cout << n - ans << endl;
	}
	else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3568
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };
int a[1005], b[1005], c[1005];
signed main() {
	int x, y, z, k; cin >> x >> y >> z >> k;
	rep(i, x)cin >> a[i];
	rep(i, y)cin >> b[i];
	rep(i, z)cin >> c[i];
	sort(a, a + x);
	sort(b, b + y);
	sort(c, c + z);
	vector<int>xy;
	rep(i, x) {
		rep(j, y) {
			xy.push_back(a[i] + b[j]);
		}
	}
	sort(xy.begin(), xy.end());
	int lb = 0, ub = 1e13;
	while (ub - lb > 1) {
		int mi = (ub + lb) / 2;
		int cnt = 0;
		rep(i, z) {
			cnt += xy.end() - lower_bound(xy.begin(), xy.end(), mi - c[i]);
		}
		if (cnt < k)ub = mi;
		else lb = mi;
	}
	vector<int>ans;
	rep(i, z) {
		int pos = lower_bound(xy.begin(), xy.end(), lb - c[i])-xy.begin();
		for (int j = pos; j < xy.size(); j++) {
			ans.push_back(c[i] + xy[j]);
		}
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	rep(i, k)cout << ans[i] << endl;
}

Measured memory_bytes: 141020
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>k;
	long a,b,c;
	a=k/50+50;
	b=k%50;
	c=a-b-1;
	cout<<50<<endl;
	for(int i=0;i<50;i++)
	{
		if(i<b)
		{
			if(i==0)
			cout<<a;
			else
			cout<<" "<<a;
		}
		else
		{
			if(i==0)
			cout<<c;
			else 
			cout<<" "<<c;
		}
	}
	cout<<endl;
	return 0;
}

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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() { 
	long ans=1;
	string A,tmp="abcdefghijklmnopqrstuvwxyz";
	cin >> A;
	long t[A.size()+1][26]={},c;
	for(long i = 0; i < A.size(); i++) {
		c = A[i] - 'a';
		t[i+1][c] =  t[i][c] + 1;
      	for(int j = 0; j < tmp.size(); j++) {
        	if(tmp[j] == A[i]) {
            	continue;
            }
            c = tmp[j] - 'a'; 
          	t[i+1][c] = t[i][c];
        }
	}
	for(long i = 0; i < 2; i++) {
		ans *= (A.size()-i);
	}
	ans /= 2;
	for(long i = 0; i < A.size(); i++) {
		c = A[i] - 'a';
      	ans -= (t[A.size()][c] - t[i+1][c]);
	}
	cout << ans + 1 << endl;
	return 0;
}


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

#define   ll    long long int

const int N = 200005;
int dpl[N];
int dpr[N];

int main( )
{
    int n, k, c, i, j, l;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    s = "*" + s;
    for (i = 1; i <= n; i++) {
        if (s[i] == 'o') {
            dpl[i] = max(dpl[i - 1], 1 + dpl[max(0, i - c - 1)]);
        }
        else {
            dpl[i] = dpl[i - 1];
        }
    }
    for (i = n; i >= 1; i--) {
        if (s[i] == 'o') {
            dpr[i] = max(dpr[i + 1], 1 + dpr[min(n + 1, i + c + 1)]);
        }
        else {
            dpr[i] = dpr[i + 1];
        }
    }
    for (i = 1; i <= n; i++) {
        if (dpl[i - 1] + dpr[i + 1] < k) {
            cout << i << '\n';
        }
    }
    return 0;
}



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

int func(int x) {
    if (x % 100 != 0) return 0;
    return func(x/100) + 1;
}

int main() {
    int D, N;
    cin >> D >> N;
    int cnt = 0;
    for(int x = 1; ; ++x) {
        if (func(x) == D) {
            ++cnt;
            if (cnt == N) {
                cout << x << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

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

int main(){
    int n, m;
    cin >> n >> m;
    cout << ( n - 1 ) * ( m - 1 ) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		Long total  = 0L;
		for(int i = 1; i <= N; ++i){
	            if(i % 3 == 0 && i % 5 == 0){
	            	continue;
	            }else if(i % 3 == 0){
	                continue;
	            }else if(i % 5 == 0){
	            	continue;
	            }else{
	                total += i;
	            }
	     }
		System.out.println(total);
	}
}

Measured memory_bytes: 48216
import fractions as fr
k = int(input())
ans = (k+1)*k//2
tttt = [[0]*(k+1) for _ in range(k+1)]
for i in range(1, k+1):
  for j in range(1, k+1):
    if i == j:
      continue
    else:
      if tttt[i][j] != 0:
        g = tttt[i][j]
        ans += 3*g
      else:
        g = fr.gcd(i,j)
        tttt[i][j] = g
        tttt[j][i] = g
        ans += 3*g
for i in range(1, k-1):
  for j in range(i+1, k):
    for l in range(j+1, k+1):
      temp = tttt[i][j]
      temp2 = tttt[temp][l]
      ans+= 6*temp2
print(ans)

Measured memory_bytes: 11000
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	Int x4 = 0;
	Int odd = 0;
	Int even = 0;

	Int temp;
	for (Int i = 0; i < N; i++) {
		cin >> temp;
		if (temp % 2) {
			odd++;
			continue;
		}
		if (temp % 4 == 0) {
			x4++;
			continue;
		}
		even++;
	}
	if(even%2==0){
		if (x4 == 0 && odd == 1) {
			cout << "No\n";
		}
		else {
			cout << ((x4 + 1 >= odd) ? "Yes\n" : "No\n");
		}
	}
	else {
		odd++;
		if (x4 == 0 && odd == 1) {
			cout << "No\n";
		}
		else {
			cout << ((x4 + 1 >= odd) ? "Yes\n" : "No\n");
		}
	}
}	

Measured memory_bytes: 256
#include<iostream>
using namespace std;
signed main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0){cout<<1<<endl; return 0;
	}
	if(b==0){cout<<2<<endl; return 0;
	}
	if(c==0){cout<<3<<endl; return 0;
	}
	if(d==0){cout<<4<<endl; return 0;
	}
	if(e==0){cout<<5<<endl; return 0;
	}
} 

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-13;

int v[300009];
LL l[300009];
LL r[300009];

int main(){
	DRI(n);
	REP(i,3*n){
		RI(v[i]);
	}
	priority_queue<int> pq;
	priority_queue<int,vector<int>,greater<int> > pq2;
	LL csum=0;
	REP(i,3*n){
		pq2.push(v[i]);
		csum+=v[i];
		if(SZ(pq2)>n){
			csum-=pq2.top();pq2.pop();
		}
		if(SZ(pq2)==n)l[i]=csum;else l[i]=-INF;
	}
	csum=0;
	for(int i=3*n-1;i>=0;i--){
		pq.push(v[i]);
		csum+=v[i];
		if(SZ(pq)>n){
			csum-=pq.top();pq.pop();
		}
		if(SZ(pq)==n)r[i]=csum;else r[i]=INF;
	}
	LL ans=-INF;
	REP(i,3*n-1){
		ans=max(ans,l[i]-r[i+1]);
	}
	printf("%lld",ans);
}


Measured memory_bytes: 7032
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N;
ll A[MAXN], B[MAXN];

priority_queue <pair <ll, int> > pq;

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < N; i++)
        cin >> B[i];

    for (int i = 0; i < N; i++)
        if (B[i] > A[i])
            pq.push(make_pair(B[i], i));

    ll ans = 0;
    while (!pq.empty())
    {
        ll xv = pq.top().first;
        int cloc = pq.top().second;
        pq.pop();
        if (B[cloc] != xv) continue;

        ll csum = (B[(cloc+1)%N] + B[(cloc+N-1)%N]);
        if (B[cloc] <= csum)
            break;
        if (A[cloc] % csum == B[cloc] % csum)
        {
            ans += (B[cloc] - A[cloc]) / csum;
            B[cloc] = A[cloc];
        }
        else
        {
            ans += B[cloc] / csum;
            B[cloc] %= csum;
        }
        //cout << cloc << " " << B[cloc] << "\n";
        if (B[cloc] > A[cloc])
            pq.push(make_pair(B[cloc], cloc));
    }
    for (int i = 0; i < N; i++)
        if (A[i] != B[i])
            ans = -1;
    cout << ans << "\n";
}

Measured memory_bytes: 9584
#include<stdio.h>
#define B 100
main()
{
  int N;//要素
  int A[B];//配列
  int i,n,j,temp=0,num=0,min,k;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=0;i<N-1;i++)
    {
      min=A[i];
      k=i;
      for(j=i;j<N;j++)
	{
	if(A[j]<min)
	  {
	    min=A[j];
	    k=j;
	   
	  }
    }
  temp=A[i];
  A[i]=A[k];
  A[k]=temp;
  if(i!=k)num++;
 
}


 for(i=0;i<N-1;i++)
    {
      printf("%d ",A[i]);
    }
  printf("%d\n",A[N-1]);
 printf("%d\n",num);
  return 0;
}

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

int main()
{
    int N, sum;
    cin >> N;
    
    int tmp = N;
    while(tmp > 0)
    {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (N % sum == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# coding: utf-8
# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    A, B, C, D = map(int, input().split())
    while True:
        C = C - B
        if C <= 0:
            print ('Yes')
            break
        A = A - D
        if A <= 0:
            print('No')
            break

if __name__ == "__main__":
    main()

Measured memory_bytes: 9172
class Numeric
  def clamp( range)
    [[range.begin, self].max, range.end].min
  end
end

h,w = gets.chomp.split(" ").map(&:to_i)
canvas = []
h.times do
  canvas << gets.chomp.split("")
end

h.times do |i|
  w.times do |j|
    if canvas[i][j] == "#"
      surround = [{y:i-1,x:j}, {y:i+1, x:j}, {y:i, x:j-1}, {y:i, x:j+1}].map{|hash| {y:hash[:y].clamp(0..h-1), x:hash[:x].clamp(0..w-1)}}

      check = false
      surround.reject{|hash| hash == {y:i,x:j}}.each do |xy|
        if canvas[xy[:y]][xy[:x]] == "#"
          check = true
          break
        end
      end
      next if check

      puts "No"
      exit

    end
  end
end

puts "Yes"

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
	int m,k;cin>>m>>k;
	int n=1<<m;
	if(k>=n)
	{
		cout<<-1<<endl;return 0;
	}
	else
	{
		if(m==1)
		{
			if(k==1)
			{
				cout<<"-1"<<endl;return 0;
			}
			else if(k==0)
			{
				cout<<"0 0 1 1"<<endl;return 0;
			}
		}
		for(int i=0;i<n;i++)
		{
			if(i!=k) v.push_back(i);
		}
		v.push_back(k);
		for(int i=n-1;i>=0;i--)
		{
			if(i!=k) v.push_back(i);
		}
		v.push_back(k);
		for(int i=0;i<v.size();i++)
		{
			if(i==0) cout<<v[i];
			else cout<<" "<<v[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 2932
#include <stdio.h>
#include <stdlib.h>

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int d[k];
  int c[n+1];
  for(int i=1;i<=n;i++) c[i]=0;

  for(int i=0;i<k;i++){
    scanf("%d", &d[i]);
    for(int j=0;j<d[i];j++){
      int ai;
      scanf("%d", &ai);
      c[ai]++;
    }
  }

  int ans=0;  
  for(int i=1;i<=n;i++){
    if(c[i]==0) ans++;
  //  printf("c[%d]: %d\n", i, c[i]);
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 2156
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String a=scan.next();
		int count=0;
if(a.charAt(0)=='1') {
			count++;
		}if(a.charAt(1)=='1') {
			count++;
		}if(a.charAt(2)=='1') {
			count++;
		}
		System.out.println(count);
	}
}

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

int main(){
    ll ans;
    int n; cin >> n;
    vector<ll> a(n+1), b(n);
    rep(i,n+1) cin >> a.at(i);
    rep(i,n) cin >> b.at(i);

    ans = accumulate(a.begin(), a.end(), 0LL);
    
    for(int i = 0; i < n; i++){
        
        ll rem = a.at(i) - b.at(i);
        if(rem < 0){
            a.at(i) = 0;
            a.at(i+1) += rem;
            if(a.at(i+1) < 0){ a.at(i+1) = 0;}  
        }else{
            a.at(i) = rem;
        }
    }
    //for(auto a:a){ cout << a << " ";} cout << endl;
    ans -= accumulate(a.begin(), a.end(), 0LL);

    cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
list_v = [int(i) for i in input().split()]
list_c = [int(j) for j in input().split()]
ans = 0
for i in range(0, n):
    if list_v[i] - list_c[i] > 0:
        ans += (list_v[i] - list_c[i])
print(ans)

Measured memory_bytes: 9092
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int N = ReadInt();
    int[] A = ReadIntArray(), B = ReadIntArray();
    // どこまで右に行って、どこで下に下がるのか
    // 上は左から足す、下は右から足す
    // どの組み合わせにすると最大になるかループして終わり
    int[] upSide = new int[N], downSide = new int[N];
    upSide[0] = A[0];
    downSide[N-1] = B[N-1];
    for (int i = 1; i < N; i++) {
      upSide[i] = upSide[i-1] + A[i];
      downSide[N-i-1] = downSide[N-i] + B[N-i-1];
    }
    int res = 0;
    for (int i = 0; i < N; i++) {
      int count = upSide[i] + downSide[i];
      if (count > res) res = count;
    }
    Console.WriteLine(res);
  }

  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<cstring>

int n,x,po[200001],f[200001],ans;

bool check(int a,int b,int c) {return a<b&&b<c||b<c&&c<a||c<a&&a<b;}

int main()
{	
	scanf("%d",&n); ans=0;
	for (int i=1; i<=n; i++) scanf("%d",&x),po[x]=i;
	for (int i=n-1; i>=1; i--)
		if (!ans) {if (po[i+1]<po[i]) ans++,f[i]=i+1;}
		else if (check(po[i],po[i+1],po[f[i+1]])) f[i]=f[i+1]; else f[i]=i+1,ans++;
	printf("%d\n",ans);
	return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

double PI = 3.1415;

double calc(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    ll f[N] = {}, g[N] = {};
    rep(i, N){
        rep(j, N){
            if(A[i] > A[j]) f[i]++;
        }
    }
    rep(i, N){
        for(int j = i+1; j < N; j++){
            if(A[i] > A[j]) g[i]++;
        }
    }
    ll ans = 0;
    rep(i, N){
        ans = (ans + ((K*(K-1)/2) % mod)*f[i]) % mod;
        ans = (ans + K*g[i]) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 1<<30

int main(){
	int n;
	cin >> n;
	vector<int> per;
	for(int i = 0; i < n; i++) per.pb(i);
	vector<int> X, Y;
	int x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		X.pb(x); Y.pb(y);
	}
	double sum = 0;
	int cnt = 0;
	do{
		double d = 0;
		int dx, dy;
		for(int i = 0; i < n - 1; i++){
			dx = X[per[i+1]] - X[per[i]];
			dy = Y[per[i+1]] - Y[per[i]];
			d += sqrt(dx*dx + dy*dy);
		}
		sum += d;
		cnt++;
	}while(next_permutation(all(per)));
	cout << fixed << setprecision(10) << sum / cnt << endl;
	return 0;
}


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

int main(){
    /* A 
    int n,x,t;
    cin >> n >> x >> t;
    int ans;
    if(n%x!=0)ans=(n/x+1)*t;
    else ans=n/x*t;
    cout << ans << endl;*/

    /* B
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        ans += s.at(i) - '0';
    }
    cout << ((ans%9==0)? "Yes":"No") << endl;*/

    /* C */
    int n;
    cin >> n;
    vector<int64_t> a(n);
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    int64_t ans=0;
    for(int i=1;i<n;i++){
        if(a[i-1]>a[i]){
            ans += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    string s;
    cin>>s;
    string t;
    cin>>t;
    string ans="";
    for(int i=0; i<t.size()-1; i++)
        ans+=t[i];
    if(ans==s)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3572
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      if(i >= k) {
        if(a[i] > a[i - k]) {
          System.out.println("Yes");
        } else {
          System.out.println("No");
        }
      }
    }
    System.out.println();
  }
}

Measured memory_bytes: 60664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}


 
int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if(a < b)
        swap(a,b);
    if(a < c)
        swap(a,c);
    if(b < c)
        swap(b,c);

    if(a == b + c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    


}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a[1000], b[1000],x,c,d,e,f;
	int i = 0;
	int r = 1;
	while (r) {
		scanf("%d %d",&a[i],&b[i]);
		if(a[i] == 0 && b[i] == 0) {
			r = 0;
		}
		i++;
	}
	for (x = 0; x < i; x++) {
		c = a[x];
		d = b[x];
		for (e = 0; e < a[x]; e++) {
			for (f = 0; f < b[x]; f++) {
				if (e == 0 || e == a[x] - 1 || f == 0 || f == b[x]-1) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		if (x != i - 1) {
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2612
#include<bits/stdc++.h>
using namespace std;
int n,m,q,f[3][2010][2010];
char s[2010][2010];
inline int orz(int t,int i,int j,int k,int l)
{
	return f[t][k][l]-f[t][i-1][l]-f[t][k][j-1]+f[t][i-1][j-1];
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,l;
	scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=n;i++)
	  scanf("%s",&s[i][0]+1);
	for(i=1;i<=n;i++)
	  for(j=1;j<=m;j++)
		if(s[i][j]=='1')
		  {
		   f[0][i][j]=1;
		   if(i<n && s[i+1][j]=='1')
		     f[1][i][j]=-1;
		   if(j<m && s[i][j+1]=='1')
		     f[2][i][j]=-1;
		  }
	for(i=0;i<=2;i++)
	  for(j=1;j<=n;j++)
	    for(k=1;k<=m;k++)
	      f[i][j][k]+=f[i][j][k-1];
	for(i=0;i<=2;i++)
	  for(j=1;j<=n;j++)
	    for(k=1;k<=m;k++)
	      f[i][j][k]+=f[i][j-1][k];
	while(q--)
	  {
	   scanf("%d%d%d%d",&i,&j,&k,&l);
	   printf("%d\n",orz(0,i,j,k,l)+(i<k?orz(1,i,j,k-1,l):0)+(j<l?orz(2,i,j,k,l-1):0));
	  }
	return 0;
}


Measured memory_bytes: 52992
#include <stdio.h>

int main(){
    char num[4];
    int count = 0, i = 0;

    scanf("%s", num);
    while(i <= 4){
        if(num[i] == '2'){
            count += 1;
        }
        i++;
    }
    printf("%d\n", count);

    return 0;

}

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

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


template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  Int n;
  F f;
  G g;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(Int n_,F f,G g,T ti):
    f(f),g(g),ti(ti){
    init(n_);
  }
  void init(Int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
  }
  void build(Int n_, vector<T> v){
    for(Int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(Int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(Int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(Int a,Int b){
    T vl=ti,vr=ti;
    for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }

  Int find(Int a,Int b,function<bool(T)> &check,Int k,Int l,Int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n-1) return k-(n-1);
    Int m=(l+r)>>1;
    Int vl=find(a,b,check,k*2+1,l,m);
    if(~vl) return vl;
    return find(a,b,check,k*2+2,m,r);
  }
  
  Int find(Int a,Int b,function<bool(T)> &check){
    return find(a,b,check,0,0,n);
  }
  
};


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(n,0);
  for(Int i=1;i<n;i++) cin>>a[i];
  for(Int i=1;i<n;i++) a[i]+=a[i-1];
  
  auto b=make_v<Int>(m,n);
  for(Int i=0;i<n;i++)
    for(Int j=0;j<m;j++)
      cin>>b[j][i];

  auto dp=make_v<Int>(n+1,n+1);
  fill_v(dp,0);
  
  for(Int i=0;i<m;i++){
    using P = pair<Int, Int>;
    SegmentTree<P, P>::F f=[&](P a,P b){return max(a,b);};
    SegmentTree<P, P> seg(n,f,f,P(-1,-1));
    vector<P> v;
    for(Int j=0;j<n;j++) v.emplace_back(b[i][j],j);
    seg.build(n,v);
    
    queue<P> q;
    q.emplace(0,n);
    while(!q.empty()){
      Int l,r;
      tie(l,r)=q.front();q.pop();
      if(l==r) continue;
      Int k=seg.query(l,r).second;
      
      //cout<<i<<":"<<l<<" "<<r<<":"<<k<<" "<<b[i][k]<<endl;
      
      dp[l][k]+=b[i][k];
      dp[l][r]-=b[i][k];
      
      dp[k+1][k]-=b[i][k];
      dp[k+1][r]+=b[i][k];
	    
      q.emplace(l,k);
      q.emplace(k+1,r);
    }
  }

  for(Int i=0;i<=n;i++)
    for(Int j=1;j<=n;j++)
      dp[i][j]+=dp[i][j-1];

  for(Int i=1;i<=n;i++)
    for(Int j=0;j<=n;j++)
      dp[i][j]+=dp[i-1][j];
  
  Int ans=0;
  for(Int i=0;i<n;i++)
    for(Int j=i;j<n;j++)
      chmax(ans,dp[i][j]-(a[j]-a[i]));

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 204176
#include <stdio.h>

void p2(unsigned int n){
	for(int i=31;i>=0;i--)printf("%u",(n>>i)&1);
	puts("");
}
int main(){
	unsigned int n,m;
	scanf("%u%u",&n,&m);
	p2(n&m);
	p2(n|m);
	p2(n^m);
}


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

int main(){
    string S,T;
    cin >> S >> T;
    int ans = T.size();
    rep(i,S.size()-T.size()+1){
        int diff = 0;
        rep(j,T.size()){
            if(T.at(j) != S.at(i+j)){
                diff += 1;
            }
        }
        ans = min(ans,diff);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int main(){
	int K, S;
	unsigned long long int num = 0;
	cin >> K >> S;
	for(int X = 0; X <= K; X++){
		for(int Y = 0; Y <= K; Y++){
			int Z = S - X - Y;
			if(0 <= Z && Z <= K){
				num++;
			}
		}
	}
	cout << num;
}

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

using namespace std;

const int MAX_H = 100;
const int MAX_W = 100;

int H, W;
char orchard[MAX_H][MAX_W + 1];
bool passed[MAX_H][MAX_W];

void dfs(int h, int w, const char c)
{
  if (h < 0 || H <= h) return;
  if (w < 0 || W <= w) return;
  if (orchard[h][w] != c) return;
  if (passed[h][w]) return;

  passed[h][w] = true;

  dfs(h + 1, w, c);
  dfs(h - 1, w, c);
  dfs(h, w + 1, c);
  dfs(h, w - 1, c);

  return;
}

int solve()
{
  int res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (!passed[i][j]) {
        res++;
        dfs(i, j, orchard[i][j]);
      }
    }
  }

  return res;
}

int main()
{
  while (true) {
    scanf("%d %d", &H, &W);

    if (H == 0 && W == 0) break;

    for (int i = 0; i < H; i++) {
      scanf("%s", orchard[i]);
      orchard[i][W] = 0;

      for (int j = 0; j < W; j++) {
        passed[i][j] = false;
      }
    }

    printf("%d\n", solve());
  }

  return 0;
}


Measured memory_bytes: 2916
#include <bits/stdc++.h>
using namespace std;
using ull = long long;
const ull MOD = 998244353;

ull d[100001];
ull cnt[100001];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        cnt[d[i]]++;
    }

    if (!(cnt[0] == 1 && d[0] == 0)) {
        cout << "0\n";
        return 0;
    }

    ull ans = 1;
    for (int i = 1; i < n - 1; i++) {
        for (int j = 0; j < cnt[i + 1]; j++) {
            ans *= cnt[i];
            ans %= MOD;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
loc_x=0
loc_y=0
judge=0
for i in range(n):
    if txy[i][0]%2==0:
        if (txy[i][1]+txy[i][2])%2!=0:
            judge+=1
    elif (txy[i][1]+txy[i][2])%2==0:
        judge+=1
    temp = abs(loc_x-txy[i][1])+abs(loc_y-txy[i][2])
    if i == 0:
        if temp > txy[0][0]:
            judge+=1
    else:
        if temp > txy[i][0]-txy[i-1][0]:
            judge+=1
    loc_x = txy[i][1]
    loc_y = txy[i][2]
print('No') if judge else print('Yes')

Measured memory_bytes: 27380
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  map<ll, ll> mp;
  for(int i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    mp[tmp]++;
  }
  int cnt = 0;
  for(auto p : mp) {
    if(p.first < p.second) {
      cnt += p.second - p.first;
    } else if(p.first > p.second) {
      cnt += p.second;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 6272
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define pb(n) push_back(n)
#define endl '\n'
#define P(x)  cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, count = 0; string s; char c;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  string s,t;
  IN(s);
  IN(t);
  ll size = s.size();
  bool flg = true;
  REP(i,size) {
    flg = true;
    REP(j,size) {
      if (s[(i+j)%size] != t[j]) {
        flg = false;
      }
    }
    if (flg) {
      break;
    }
  }

  if (flg) {
    OUT("Yes");
  } else {
    OUT("No");
  }
}


Measured memory_bytes: 256
//======================================
//author @Amit Singh : global_const
//======================================
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define yeah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int int
#define vi vector<int>
#define pb push_back
#define loop(i,n) for(int i=0;i<n;++i)
#define pii pair<int,int>
#define mp make_pair
signed main()
{yeah;
 char c;
 cin>>c;
 if(isupper(c))
 	cout<<"A"<<endl;
 else
 	cout<<"a"<<endl;
 return 0;
}

Measured memory_bytes: 3632
N , A , B = map(int,input().split())
ans = 0
s = 0
for i in range(1,N + 1):
    t = i
    ans = 0
    while 1:
        ans += t % 10
        t = t // 10
        if  t == 0:
            if A <= ans and B >= ans:
                s += i
            break
print(s)


Measured memory_bytes: 9128
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

struct UnionFind {
    vector<int> data;
    UnionFind(int N) : data(N, -1) { }
    // xとyを併合する
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    // xとyが同じ集合にあるか判定する
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    // xを含む集合の要素数を求める
    int size(int x) {
        return -data[root(x)];
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
};

int main(){
    iostream_init();
    int N, K, L;
    while(cin >> N >> K >> L) {
        UnionFind uf1(N);
        UnionFind uf2(N);
        REP(i, K) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            uf1.unite(a, b);
        }
        REP(i, L) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            uf2.unite(a, b);
        }
        unordered_map<LL, vector<int>> m;
        REP(i, N) {
            int t1 = uf1.root(i);
            int t2 = uf2.root(i);
            LL x = ((LL)t1) << 32 | t2;
            m[x].push_back(i);
        }
        vector<int> answer(N);
        for(auto p : m) {
            int size = p.second.size();
            for(auto x : p.second) {
                answer[x] = size;
            }
        }
        REP(i, N) {
            cout << answer[i];
            if(i != N-1) {
                cout << " ";
            } else {
                cout << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 19272
using System;
class main
{
    static void Main(string[] args)
    {
        //int g = 1;
        //int[] a = new int[2];
        //string[] i = Console.ReadLine().Split(' ');
        //string[] j = Console.ReadLine().Split('\r');
        //int j = int.Parse(Console.ReadLine());
        //decimal j = decimal.Parse(Console.ReadLine());
        //double j = double.Parse(Console.ReadLine());
        //int y = int.Parse(i[0]);
        //int x = int.Parse(i[1]);
        //int z = int.Parse(i[2]);
        //a[0] = int.Parse(i[0]);
        //a[1] = int.Parse(i[1]);
        //a[2] = int.Parse(i[2]);

        for (int a = 1; a <= 9; ++a)
        {
            for (int b = 1; b <= 9; ++b)
            {
                Console.WriteLine(a + "x" + b + "=" + (a*b));
            }
        }

            //Console.WriteLine((j*j*Math.PI) + " " + (2*j*Math.PI));

            /*int d = a[0] / a[1];
            int r = a[0] % a[1];
            decimal f = (decimal)a[0] / (decimal)a[1];
            Console.WriteLine(d + " " + r + " " + f);*/

            /*int i = 1;
            while (true)
            {
                string[] s = Console.ReadLine().Split(' ');
                a[0] = int.Parse(s[0]);
                a[1] = int.Parse(s[1]);
                if (a[0] == 0 && a[1] == 0)
                    break;
                Array.Sort(a);
                Console.WriteLine(a[0] + " " + a[1]);
                i++;
            }*/

            /*if (y < x)
            {
                Console.WriteLine("a" + " < " + "b");
            }
            if (y > x)
            {
                Console.WriteLine("a" + " > " + "b");
            }
            if (y == x)
            {
                Console.WriteLine("a" + " == " + "b");
            }*/

            //Array.Sort(a);
            /*Console.WriteLine(a[0] + " " + a[1] + " " + a[2]);
            while(g <= 1000)
            {
                Console.WriteLine("Hello World");
                ++g;
            }*/

            /*int i = 1;
            while (true)
            {
                string s = Console.ReadLine();
                if (s == "0")
                    break;
                Console.WriteLine("Case {0}: {1}", i, s);
                i++;
            }*/

            /*for (int s = 0; s < j.Length; ++s)
            {
                Console.WriteLine("Case " + (s+1) + ": " + j[s]);
            }
            Console.WriteLine(g);*/
            Console.ReadKey();
    }
}

Measured memory_bytes: 5580
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

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

    int n, x; cin >> n >> x;
    vector<int> l(n); for (int& y : l) cin >> y;
    int ans = 1;
    int d = 0;
    for (int i = 0; i < n; i++) {
        d += l[i];
        if (d <= x) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  double n, answer;
  cin >> n;
  
  if(fmod(n, 2) == 0) answer = 0.5;
  else answer = (n + 1) / (2 * n);
  
  cout << fixed << setprecision(10) << answer << endl;
}

Measured memory_bytes: 256