akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int n, m, s, g1, g2; cin >> n >> m >> s >> g1 >> g2&&n;) {
		s--, g1--, g2--;
		static const int N = 101;
		static int wf[N][N];
		rep(i, 0, n)rep(j, 0, n)wf[i][j] = INF;
		rep(i, 0, n)wf[i][i] = 0;
		rep(i, 0, m) {
			int s, d, w; cin >> s >> d >> w;
			s--, d--;
			wf[s][d] = min(wf[s][d], w);
		}

		rep(k, 0, n)rep(i, 0, n)rep(j, 0, n) {
			if (wf[i][k] != INF&&wf[k][j] != INF)
				wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
		}

		int ans = INF;
		rep(k, 0, n) {
			if (wf[s][k] != INF&&wf[k][g1] != INF&&wf[k][g2] != INF)
				chmin(ans, wf[s][k] + wf[k][g1] + wf[k][g2]);
		}
		cout << ans << endl;

	}
	return 0;
}

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

int main(){
	int n,c;cin>>n>>c;
	vector<int> v(n),w(n);
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	int mxv=100002;
	vector<long long> DP(mxv+3,INT_MAX);
	DP[0]=0;
	for(int i=0;i<n;i++){
		for(int val=mxv;val>=0;val--){
			DP[val]=min(DP[val],(val>=v[i])?w[i]+DP[val-v[i]]:INT_MAX);
		}
	}
	int ans=0;
	for(int val=0;val<=mxv;val++){
		if(DP[val]<=c) ans=val;
	}
	cout<<ans;
}

Measured memory_bytes: 1024
x1,y1,x2,y2 = map(int, input().split())

x3 = x2 + (y1-y2)
y3 = y2 + (x2-x1)

x4 = x1 + (y1-y2)
y4 = y1 + (x2-x1)

print(x3,y3,x4,y4)

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> x(n);
  for (int i = 0; i < m; i++) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    x[t].emplace_back(s);
    x[s].emplace_back(t);
  }
  vector<int> dist(n, -1);
  queue<int> que;

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (dist[i] != -1) continue;
    dist[i] = 1;
    int count = 1;
    que.push(i);
    while (!que.empty()) {
      int v = que.front();
      que.pop();

      for (int to : x[v]) {
        if (dist[to] == -1) {
          dist[to] = dist[v] + 1;
          count++;
          que.push(to);
        }
      }
    }
    ans = max(count, ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15420
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

const int M = 1e5 + 1;
vi graph[M];
int visited[M] = {0};

int dfs(int source)
{
    int d = 0;
    for (int a : graph[source])
    {
        if (!visited[a]) dfs(a);
        d = max(d, visited[a]);
    }
    visited[source] = d+1;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m; cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int u,v; cin >> u >> v;
        graph[u].pb(v);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (!visited[i]) dfs(i);
        ans = max(ans, visited[i]);
    }
    cout << ans-1;
    return 0;
}

Measured memory_bytes: 8064
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long o=0;
        long e=0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            if(A[i]%2==0){
            e++;
            }else{
            o++;
            }
        } 
    if(o%2==0){
    System.out.println("YES");
     }else{
    System.out.println("NO");
}
    }
}


Measured memory_bytes: 51796
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<long int> h(n);
  vector<vector<int> > line(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    line[a].push_back(b);
    line[b].push_back(a);
  }

  int cnt = 0;
  vector<int> good(n, 0);

  for (int i = 0; i < n; i++) {
    if (good[i] != 0)
      continue;
    long int now_height = h[i];
    for (auto it = line[i].begin(); it < line[i].end(); it++) {
      int j = *it;
      if (i == j)
        continue;
      if (h[j] < now_height)
        good[j] = -1;
      else {
        good[i] = -1;
      }
    }
    if (good[i] == 0) {
      good[i] = 1;
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 9156
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int r = sc.NextInt();

        Console.WriteLine(Math.PI * (r + r));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s[3];
  REP(i,3) cin >> s[i];
  printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);

  return 0;
}

Measured memory_bytes: 256
def f_c():
    l, r = map(int, input().split())

    c = 2019
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i%2019 == 0 or j%2019==0:
                print(0)
                return 0
            elif i == j:
                pass
            else:
                c = min(i*j%2019, c)
    print(c)

if __name__ == "__main__":
    f_c()


Measured memory_bytes: 3060
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
alp = "abcdefghijklmnopqrstuvwxyz"

def Mo(n,q,c,qi):
    ans = [0]*q
    ln = [-1]*(n+1)

    #BITの構成
    BIT = [0]*(n+1)
    def BIT_query(idx):
        res_sum = 0
        while idx > 0:
            res_sum += BIT[idx]
            idx -= idx&(-idx)
        return res_sum
    def BIT_update(idx,x):
        while idx <= n:
            BIT[idx] += x
            idx += idx&(-idx)
        return

    #Rが小さい方から見ていく,BITによる累積和の処理を含む
    pr = 0
    for i,l,r in qi:
        for j in range(pr,r):
            cj = c[j]
            ij = ln[cj]
            if ij != -1:
                BIT_update(ij,-1)
            ln[cj] = j+1
            BIT_update(j+1,1)
        pr = r
        ans[i] = BIT_query(r)-BIT_query(l-1)
    return ans

def main():
    n,q = map(int,ipt().split())
    c = [int(i) for i in ipt().split()]
    qi = []
    base = 10**6+1
    for i in range(q):
        l,r = map(int,ipt().split())
        qi.append(r*(base**2)+l*base+i)
    qi.sort()

    qs = [(i%(base),(i//base)%base,i//(base**2))for i in qi]

    ans = Mo(n,q,c,qs)

    for i in ans:
        print(i)

    return None

if __name__ == '__main__':

    main()


Measured memory_bytes: 220192
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	vector<int> ans;
	int back = -1;
	for (int i = 0; i < k+1; ++i) {
		int now_itr = 0;
		if (back == 0) now_itr = 1;
		for (int q = 0; q < n; ++q) {
			if (back == q) continue;
			if (inputs[now_itr] > inputs[q]) {
				now_itr = q;
			}
		}
		for (int q = 0; q < n; ++q) {
			if (q == now_itr||q == back) continue;
			inputs[q]--;
			if (inputs[q] < 0) {
				cout << -1 << endl;
				return 0;
			}
			ans.push_back(q);
		}
		ans.push_back(now_itr);
		inputs[now_itr]--;
		if (inputs[now_itr] < 0) {
			cout << -1 << endl;
			return 0;
		}
		back = now_itr;
	}
	cout << ans.size() << endl;
	REP(i, ans.size()) {
		if (i != 0) cout << " ";
		cout << ans[i]+1;
	}
	cout << endl;
}

Measured memory_bytes: 256
import scala.math._
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, X, Y = in.nextInt
  val counts = Array.fill(N + 1)(0)
  for {
    s <- 1 to N - 1
    e <- s + 1 to N
  } counts(min(e - s, abs(X - s) + abs(Y - e) + 1)) += 1

  println(counts.tail.init.mkString("\n"))
}

Measured memory_bytes: 25672
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;
const double PI=3.14159265358979323846;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int R; cin >> R;
    cout << 2.0*PI*R << endl;
    return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>
int main(void){
  int i,j,k,n,x,c;
  while(scanf("%d %d",&n,&x),n+x){
    c=0; 
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(k=j+1;k<=n;k++){
	  if(i+j+k==x)
	    c++;
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
using namespace std;
int N;
void dfs(string s, char mx){
 if(s.length()==N)cout<<s<<endl;
 else {
   for(char c='a';c<=mx;c++){
     dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx));
   }
 }
}
int main(void){
  cin >> N;
  dfs("", 'a');
  return 0;
}


Measured memory_bytes: 1536
def fi(i, x):
    a, b = lines[i]
    return a*x+b

def find(x):
    if len(lines) == 1:
        return 0
    def f(i):
        # 0<=i<len(lines)-1
        return fi(i+1,x) > fi(i,x)
    mn, mx = 0, len(lines)-2
    idx = (mn+mx)//2
    if f(mn):
        return 0
    if not f(mx):
        return mx+1
    while mx-mn>1:
        if f(idx):
            mx, idx = idx, (mn + idx)//2
            continue
        mn, idx = idx, (mx + idx)//2
    return idx+1

def remove_lines():
    (x, y) = lines.pop()
    a, b  = x, y
    (e, f) = lines[-1]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[-2]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.pop()
    lines.append((x, y))

def insert(a, b):
    lines.append((a, b))
    if len(lines) >= 3:
        remove_lines()

N, C = map(int, input().split())
hs = map(int, input().split())
r = 0
lines = []
for i, h in enumerate(hs):
    if i!= 0:
        r = fi(find(h), h) + h**2+C
    insert(-2*h, r+h**2)
print(r)


Measured memory_bytes: 93900
#include <iostream>
#include <vector>
#include <algorithm>
     
using namespace std;
     
int main(void){
     
  int abc[3], co1 = 0, co2 = 0;

  cin >> abc[0] >> abc[1] >> abc[2];

  for(int i = 0; i < 3; i++){
    if(abc[i] == 5) co1++;
    if(abc[i] == 7) co2++;
  }

  if(co1 == 2 && co2 == 1) cout << "YES";
  else cout << "NO";
  cout << endl;
     
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

ll N,ans;
ll dp[112345][2][2][2]; //i番目の日の最大の幸福  i-1日目に使ったかどうか
ll a[112345],b[112345],c[112345];
signed main(){
    cin>>N;
    rep(i,N){
        cin>>a[i]>>b[i]>>c[i];
    }

    rep(i,N){
        dp[i+1][1][0][0]=max(dp[i][0][1][0]+a[i],dp[i][0][0][1]+a[i]);
        dp[i+1][0][1][0]=max(dp[i][1][0][0]+b[i],dp[i][0][0][1]+b[i]);
        dp[i+1][0][0][1]=max(dp[i][1][0][0]+c[i],dp[i][0][1][0]+c[i]);
    }

    ans=max({dp[N][0][0][1],dp[N][0][1][0],dp[N][1][0][0]});
    cout<<ans<<endl;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int d,g;
  cin>>d>>g;
  vector<int> p(d),c(d);
  rep(i,d)cin>>p[i]>>c[i];

  int ans=INF;

  for(int bit=0;bit<(1<<d);bit++){
    int cnt=0,sum=0;
    rep(i,d){
      if((bit>>i)&1){
        sum+=100*(i+1)*p[i]+c[i];
        cnt+=p[i];
      }
    }
    if(sum<g){
      for(int j=d-1;j>=0;j--){
        if((bit>>j)&1)continue;
        for(int k=0;k<p[j];k++){
          if(sum>=g)break;
          sum+=100*(j+1);
          cnt++;
        }
      }
    }
    cmin(ans,cnt);
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  string s;
  ll K;
  cin >> s >> K;
  REP(i, s.size()) {
    if (K == 0) break;
    if (s[i] == 'a') continue;
    if ('z' - s[i] + 1 <= K) {
      K -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
  K %= 26;
  s[s.size() - 1] += K;
  K = 0;
  if ('z' < s[s.size() - 1]) s[s.size() - 1] -= 26;
  REP(i, s.size()) cout << s[i];
  cout << endl;
}

Measured memory_bytes: 3688
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 200005
#define M 200005
#define seed 23333
#define Mo 1000000007

using namespace std;
int i,j,m,n,p,k,X,Y,x,y,C[N],fac[N],inv[N];
vector<int>v[N];
int power(int x,int y)
{
		int sum=1;
		for (;y;y>>=1)
		{
				if (y&1) sum=1ll*sum*x%Mo;
				x=1ll*x*x%Mo;
		}
		return sum;
}
int CC(int x,int y)
{
		return 1ll*fac[x]*inv[y]%Mo*inv[x-y]%Mo;
}
int main()
{
		scanf("%d%d%d",&n,&X,&Y);
		fac[0]=fac[1]=1;
		for (i=2;i<N;++i) fac[i]=1ll*fac[i-1]*i%Mo;
		for (i=0;i<N;++i) inv[i]=power(fac[i],Mo-2);
		for (i=1;i<=n;++i) scanf("%d%d",&x,&y),v[x].pb(y);
		int A=(int)1e9+5;
		int Max=0,CMax=0;
		for (i=1;i<=n;++i)
			if (v[i].size())
			{
					sort(v[i].begin(),v[i].end());
					if (!Max||v[Max][0]>v[i][0]) swap(Max,CMax),Max=i;
					else if (!CMax||v[CMax][0]>v[i][0]) CMax=i; 
			}
		for (i=1;i<=n;++i)
			if (v[i].size())
		{
				sort(v[i].begin(),v[i].end());
				int RMax; if (Max==i) 
						  {
						  	    if (CMax)
						  		RMax=v[CMax][0]; 
						  		else RMax=(int)1e9+7;
						  }else RMax=v[Max][0];
				for (j=0;j<(int)v[i].size();++j) if (v[i][j]<=X-v[i][0]||v[i][j]<=Y-RMax) v[i][j]=v[i][0];
				A=min(A,v[i][0]);
		}
		for (i=1;i<=n;++i)
			if (v[i].size()&&v[i][0]<=Y-A)
			{
					int cnt=0;
					for (j=0;j<(int)v[i].size();++j) if (v[i][j]==v[i][0]) ++cnt;
					C[++C[0]]=cnt; 
			}
		int all=0;
		for (i=1;i<=C[0];++i) all+=C[i];
		int sum=1;
		for (i=1;i<=C[0];++i) sum=1ll*sum*CC(all,C[i])%Mo,all-=C[i];
		printf("%d\n",sum); 
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[][] e = new int[n][n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(e[i], 1000 * 1000);
            e[i][i] = 0;
        }
        int[] a = new int[m];
        int[] b = new int[m];
        int[] c = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = Integer.parseInt(sc.next()) - 1;
            b[i] = Integer.parseInt(sc.next()) - 1;
            c[i] = Integer.parseInt(sc.next());
            e[a[i]][b[i]] = c[i];
            e[b[i]][a[i]] = c[i];
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    e[i][j] = Math.min(e[i][j], e[i][k] + e[k][j]);
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (c[i] > e[a[i]][b[i]]) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 25808
#include <iostream>
#define N 1100000
using namespace std;
int sosu[N];
int check(int);
int main(){
  int a,d,n,i,j,out,judge;
  for(i=0;i<N;i++) sosu[i]=1;
  sosu[0]=0;
  sosu[1]=0;
  for(i=0;i<N/2;i++){
    if(sosu[i]==1){
      for(j=i*2;j<N;j+=i){
	sosu[j]=0;
      }
    }
  }
  while(1){
    cin >> a >> d >> n;
    if(a==0&&d==0&&n==0) break;
    j=0;
    while(n){
      if(j==1) out=a;
      out=a+j*d;
      j++;
      judge=check(out);
      if(judge==1){
	n--;
      }
    }
    cout << out << endl;
  }
  return 0;
}
int check(int n){
  if(sosu[n]==1) return 1;
  else return 0;
}

Measured memory_bytes: 5456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,m;
cin>>n>>m;
ll x,sum=0;
for(ll i=0;i<m;i++)
{
    cin>>x;
    sum+=x;
}
sum=n-sum;
if(sum<0)
{
    cout<<"-1"<<endl;
}
else
{
    cout<<sum<<endl;
}
  return 0;
}



Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N;
	scan(N);
	ll ans=0;
	/*rep1(i,N-1){
		printf("%ll3d  %ll3d %ll3d   ",i,N/i,N%i);
		if(N/i==N%i) prin("o");
		else kaigyo;
	}*/
	int sqN=(int)(sqrt(N)+eps);
	for(ll i=1;i*i<N;i++){
		if(N%i==0){
			//printf("i:%d  add:%lld\n",i,(N-i)/i);
			ll m=(N-i)/i;
			if(m>0&&N/m==N%m) ans+=m;
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
    int r;
    cin >> r;
    cout << r * 2 * 3.14159265359<< endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=405;
const int mo=998244353;
int n,S1,S2,a[N],b[N];
int fac[N],inv[N],tr[N];
int f[N][N];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
void init(){
	fac[0]=inv[0]=inv[1]=1;
	For(i,2,N-1) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,N-1) inv[i]=1ll*inv[i]*inv[i-1]%mo;
	For(i,1,N-1) fac[i]=1ll*fac[i-1]*i%mo;
}
int main(){
	init();
	scanf("%d",&n);
	For(i,1,n) scanf("%d%d",&a[i],&b[i]);
	S1=S2=0; f[0][0]=mo-1;
	For(i,1,n){
		tr[0]=1;
		For(j,1,b[i]-1) tr[j]=1ll*tr[j-1]*a[i]%mo;
		For(j,1,b[i]-1) tr[j]=1ll*tr[j]*inv[j]%mo;
		Rep(j,S1,0) For(k,0,S2) For(v,0,b[i]-1)
			f[j+a[i]][k+v]=(f[j+a[i]][k+v]+mo-1ll*f[j][k]*tr[v]%mo)%mo;
		S1+=a[i]; S2+=b[i]-1;
	}
	int ans=0;
	For(i,0,S1) For(j,0,S2){
		int val=1ll*power(i,mo-1-j)*fac[j]%mo;
		val=1ll*val*S1%mo*power(i,mo-2)%mo;
		ans=(ans+1ll*val*f[i][j])%mo;
	}
	printf("%d\n",ans);
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int r;
    cin >> r;
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int n,m,i,j,x,p[N],a[N],t,q[N];
long long nk,v;
bool vis[N];
int read(){
	char c=getchar();int k=0,p=0;
	for (;c<48||c>57;c=getchar()) if (c=='-') p=1;
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;
	return p?-k:k;
}
int main(){
	for (n=read(),i=1;i<=n;i++) p[i]=read();
	m=read();scanf("%lld",&nk);
	for (i=1;i<n;i++) a[i]=i;
	for (;m--;){int x=read();swap(a[x-1],a[x]);}
	for (i=1;i<n;i++) if (!vis[i]){
		for (x=i,t=0;!vis[x];x=a[x]) vis[x]=1,q[t++]=x;
		for (j=0;j<t;j++) a[q[j]]=q[(j+nk)%t];
	}
	for (v=p[1],i=1;i<=n;i++)
		printf("%lld.0\n",v),v+=p[a[i]+1]-p[a[i]];
}

Measured memory_bytes: 2688
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int[] diff = new int[n + 1];
        diff[0] = 0;
        for (int i = 1; i < n; i++) {
            diff[i] = a[i] - a[i - 1];
        }
        diff[n] = a[0] + k - a[n - 1];

        int sum = Arrays.stream(diff).sum();
        int max = Arrays.stream(diff).max().getAsInt();
        int result = sum - max;

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 62880
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using ll = long long;
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; }
template<class itr> void cins(itr first,itr last){
  for (auto i = first;i != last;i++){
    cin >> (*i);
  }
}
template<class itr> void array_output(itr start,itr goal){
  string ans = "",k = " ";
  for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
  if (!ans.empty()) ans.pop_back();
  //PRINT(ans);
}
ll gcd(ll a, ll b) {
  return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 2510;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

struct Node{
	ll to=0;
	ll cost=0;
};
class Dijkstra{
 private:

  vector<vector<Node>> G;
  VI d;
  ll siz;
 public:
  Dijkstra(ll n){
    G.resize(n);
    siz = n;
  }
  void add_edge(ll from,ll to,ll cost){
    G[from].push_back(Node{to,cost});
  }
  vector<ll> dijkstra(ll s){
    priority_queue<P,vector<P>,greater<P>> q;
    d.assign(siz,INF);
    d[s] = 0;
    q.push(P(0,s));
    while(!q.empty()){
      P p = q.top();q.pop();
      ll v = p.second;
      if (d[v] < p.first) continue;
      for(Node &e:G[v]){
        if (chmin(d[e.to],d[v]+e.cost)){
          q.push(P(d[e.to],e.to));
        }
      }
    }
    return d;
  }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,s;
  cin >> n >> m >> s;
  Dijkstra g(2501*n); // u:2500*u+money
  ll u,v,a,b,c,d;
  rep(i,m){
    cin >> u >> v >> a >> b;
    --u;
    --v;
    rep(i,a,2501){
      g.add_edge(2501*u+i,2501*v+i-a,b);
      g.add_edge(2501*v+i,2501*u+i-a,b);
    }
  }
  rep(i,n){
    cin >> c >> d;
    rep(j,2500){
      g.add_edge(2501*i+j,2501*i+min(j+c,(ll)2500),d);
    }
  }
  vector<ll> dist = g.dijkstra(min(s,(ll)2500));
  rep(i,1,n){
    ll ans = INF;
    rep(j,2501){
      chmin(ans,dist[2501*i+j]);
    }
    print(ans);
  }
}


Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

vector<int> loc[5][2];
bool b[100][5][2];
int p[100][11];
void solve(){
	int n; cin >> n;
	rep(i, n)rep(j, 5)rep(k, 2) {
		int x; cin >> x;
		b[i][j][k] = x;
		if(x)loc[j][k].push_back(i);
	}
	rep(i, n)rep(j, 11)cin >> p[i][j];

	int ans = -mod;
	rep1(i, 1023) {
		int cop = i;
		vector<int> cnt(n, 0);
		rep(j, 5) {
			rep(l, 2) {
				int d = cop % 2; cop /= 2;
				if (d) {
					rep(k, loc[j][l].size()) {
						cnt[loc[j][l][k]]++;
					}
				}
			}
		}
		int sum = 0;
		rep(j, n) {
			sum += p[j][cnt[j]];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  int a[n+1],b[n];
  long long int count =0;
  for(int i = 0; i < n+1; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    if(a[i]-b[i]>0){
      count += b[i];
    }else if(b[i]-a[i]-a[i+1]>0){
      count += a[i]+a[i+1];
      a[i+1]=0;
    }else{
      count += b[i];
      a[i+1]=a[i+1]-b[i]+a[i];
    }
  }
  cout <<count;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
  val (N, K) = readInts()
  val A = readLongs().sortedDescending()

  var cnt = 0L
  for (i in 0 until N) {
    if (i >= K) cnt += A[i]
  }
  println(cnt)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 84212
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;

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


int digsum(int n) {
      int res = 0;
      while(n > 0) {
          res += n%10;
          n /= 10;
      }
      return res;
  }
#include <iomanip>


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

int a,b,c,d,e;
cin >> a >> b >> c >> d >> e;
if(a == 0) cout << 1 << endl;
else if (b == 0) cout << 2 << endl;
else if(c == 0) cout <<3 << endl;
else if(d == 0) cout << 4 << endl;
else cout << 5 << endl;




//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

H,W,K=map(int, sys.stdin.readline().split())
S=[ sys.stdin.readline().strip() for _ in range(H) ]
#print H,W,K
#print S

ans=float("inf")
for bit in range(2**H):
    cnt=0
    group_num=0
    GROUP={}
    for i,s in enumerate(S):
        if i==0:
            GROUP[i]=group_num
        else:
            if bit>>i-1&1==1:
                cnt+=1      #境目のカウントに+1
                group_num+=1
            GROUP[i]=group_num
    #print "GROUP :: ",GROUP

    ok=None
    VALUE=defaultdict(lambda: 0)
    w=0
    break_flag=False
    for w in range(W):
        if break_flag:  #breakフラグがTrueならループを止める
            break
        for h in range(H):
            VALUE[GROUP[h]]+=int(S[h][w])
        #現在の値がKを超えていないか
        for v in VALUE.values():
            if v<=K:
                pass
            else:
                #print "NG!",w
                if ok is None:      #okに値がない場合は、このパターンは成り立たない
                    #print "IMPOSSIBLE!"
                    cnt=float("inf")    #不可能なパターンなのでカウントに無限大を代入
                    break_flag=True     #breakフラグにTrueを代入
                    break
                else:      #以前の列で成り立たっていた場合
                    cnt+=1      #境目のカウントに+1
                    VALUE=defaultdict(lambda: 0)    #NGの場合は値を初期化して入れなおし
                    for h in range(H):
                        VALUE[GROUP[h]]+=int(S[h][w])
                    break
        else:
            ok=w
    #print "w,ok,cnt,VALUE :: ",w,ok,cnt,VALUE
    ans=min(ans,cnt)
       
print ans

Measured memory_bytes: 33900
n = int(input())
A1 = [[0 for i in range(10)] for j in range(3)]
A2 = [[0 for i in range(10)] for j in range(3)]
A3 = [[0 for i in range(10)] for j in range(3)]
A4 = [[0 for i in range(10)] for j in range(3)]
for i in range(n):
  b, f, r, v = map(int,input().split())
  if b == 1:
    A1[f-1][r-1] = A1[f-1][r-1] + v
  if b == 2:
    A2[f-1][r-1] = A2[f-1][r-1] + v
  if b == 3:
    A3[f-1][r-1] = A3[f-1][r-1] + v
  if b == 4:
    A4[f-1][r-1] = A4[f-1][r-1] + v

for i in range(3):
  print('',' '.join(map(str, A1[i])))
print('#' * 20)
for i in range(3):
  print('',' '.join(map(str, A2[i])))
print('#' * 20)
for i in range(3):
  print('',' '.join(map(str, A3[i])))
print('#' * 20)  
for i in range(3):
  print('',' '.join(map(str, A4[i])))





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

int main() {
    ll n,a,b,ans=0;cin>>n;
    ll m=sqrt(n);
    
    for(ll i=1;i<=m;++i){
        if(n%i==0){
            a=i-1;
            b=n/i-1;
//            if(a>1 && n%a!=0)ans+=a;
            if(b>1 && n%b!=0 && b!=a)ans+=b;
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<57;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int n;
vi a;

int f(int x){
	if(x==n-1) return n;
	if(a[x]==a[x+1]) return f(x+1);
	bool flag=0;
	if(a[x]<a[x+1]) flag=1;
	for(int i=x+1;i<n-1;i++){
		if(flag&&a[i]>a[i+1]) return i+1;
		if(!flag&&a[i]<a[i+1]) return i+1;
	}
	return n;
}

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int res=0,I=0;
	while(I!=n){
		I=f(I);
		res++;
	}
	cout<<res<<endl;
}

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

const int N = 100005;
int ans[N];

int main( )
{
    int n, q;
    string s;
    int i, j, k;
    cin >> n >> q;
    cin >> s;
    s = "@" + s;
    for (i = 2; i <= n; i++) {
        ans[i] += ans[i - 1];
        if (s[i - 1] == 'A' && s[i] == 'C') {
            ans[i]++;
        }
    }
    while (q--) {
        int l, r;
        cin >> l >> r;
        int c = ans[r] - ans[l - 1];
        if (s[l - 1] == 'A' && s[l] == 'C') {
            c--;
        }
        cout << c << '\n';
    }
    return 0;
}


Measured memory_bytes: 1404
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, A, B, cnt = 0, brank = 1;
	string S;

	cin >> N >> A >> B >> S;

	rep(i, N) {
		bool ok;

		if (S[i] == 'c') ok = false;
		else if (S[i] == 'a' && cnt < A + B) {
			cnt++;
			ok = true;
		}
		else if (S[i] == 'b' && cnt < A + B && brank <= B) {
			cnt++;
			brank++;
			ok = true;
		}
		else ok = false;

		cout << (ok ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
const int RATIO = 9;
const int MAX = 100;
const int TOP = 3200;
const int DIV = 400;
int main() {
	int N, a, color[RATIO], min = 0, max = 0;
	cin >> N;
	for (int i = 0;i < RATIO;i ++) color[i] = 0;
	for (int i = 0;i < N;i ++) {
		cin >> a;
		if (a >= TOP) color[RATIO - 1] ++;
		else color[a / DIV] ++;
	}
	for (int i = 0;i < RATIO - 1;i ++) {
		if (color[i]) min ++;
	}
	max = min + color[RATIO - 1];
	if (min == 0 && color[RATIO - 1] > 0) min ++;
	cout << min << " " << max;
	return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map &:to_i
AdjList = {}
Edges = (1..M).map {
  a, b = gets.split.map {|i| i.to_i-1 }
  AdjList[a] ||= []
  AdjList[b] ||= []
  AdjList[a] << b
  AdjList[b] << a
  [a, b].sort
}

def connect?(ignore_edge)
  q = [0]
  visited = {}
  visited[0] = true

  while q.size>0
    v = q.pop
    for w in AdjList[v]
      unless visited[w] or [v, w].sort==ignore_edge
        q.push w
        visited[w] = true
      end
    end
  end
  visited.size == N
end

puts Edges.map {|e| connect?(e) }.count(false)


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

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

int main() {
    cin >> n >> m;
	int cl[n] = {};
	int pen[n] = {};
    int p;
	string q;
	for(int i = 0; i < m; ++i) {
    	cin >> p >> q;
    	if (q == "AC" && cl[p-1] == 0) {
        	cl[p-1] = 1;
        	cnt++;
        	sum += pen[p-1];
        } else if (q == "WA" && cl[p-1] == 0) {
        	pen[p-1]++;
        }
    }
	dbg(accumulate(cl,cl+n,0));
	dbg(sum);
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

constexpr int MOD = 1e+9 + 7;

// Greatest Common Multiple (GCD)
// 2数の最大公約数 by ユークリッド互助法
template <typename T>
T gcd(T a, T b)
{
    if(b == 0) return a;
    else return gcd<T>(b, a % b);
}

// 繰り返し二乗法(Exponentiation by squaring)
// n^8 = ((n^2)^2)^2 を利用する
template <typename T>
T pow_mod(T n, T p, T m)
{
    if(p == 0) return 1;
    if(p%2 == 1) return pow_mod<T>(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod<T>(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

int main()
{
    int N;
    cin >> N;
    map<pair<long long,long long>, pair<int,int>> P;
    int num_zeros = 0;
    REP(i, N){
        long long A, B;
        cin >> A >> B;
        if(A == 0 and B == 0){ // (0, 0) は全てのイワシと仲が悪い
            ++num_zeros;  
            continue;
        }
        // (0, □) は (□, 0) の全てのイワシと仲が悪い
        /*
        if(A == 0){
            P[make_pair(A, 1)].first++;
            continue;
        }
        if(B == 0){
            P[make_pair(B, 1)].second++;
            continue;
        }
        */
        // A/B の組を記録
        long long GCD = gcd<long long>(A, B);
        A /= GCD;
        B /= GCD;
        if(B < 0){  // A < 0 となるようにする
            A = -A;  
            B = -B;
        }
        // A の正負で first, second を分類
        if(A > 0) P[make_pair(A, B)].first++;
        else P[make_pair(B, -A)].second++;
    }

    long long ans = 1;
    for(auto p: P){
        int num_i = p.second.first;
        int num_j = p.second.second;
        long long num_pairs = pow_mod<long long>(2, num_i, MOD) + pow_mod<long long>(2, num_j, MOD) - 1;
        ans *= num_pairs%MOD;
        ans %= MOD;
    }
    cout << (ans+num_zeros-1+MOD)%MOD << endl;

    return 0;
}

Measured memory_bytes: 15868
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<deque>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<vector>

#define MAX(x,y) ((x>y)?(x):(y))
#define min(x,y) ((x<y)?(x):(y))
typedef long long ll;

using namespace std;

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

struct room{
	int x,y,l;
	room(int x0,int y0,int l0){x=x0;y=y0;l=l0;}
	bool operator < (room a) const {return (l>a.l);}
};
int L[2][505][505],f[505][505];
int d[2][250005],e;
int main(){
	int i,j,k;
	int w[2],h[2],r,x[2],y[2],cx,cy;
	int ma,ans;
	priority_queue<room> q;
	
	while(1){
		scanf("%d",&r);
		if(r==0)break;
		memset(L,-1,sizeof(L));
		
		for(k=0;k<2;k++){
			scanf("%d%d%d%d",&w[k],&h[k],&x[k],&y[k]);
			for(i=1;i<=h[k];i++)for(j=1;j<=w[k];j++){
				scanf("%d",&L[k][i][j]);
				
			}
		}
		
		memset(d,-1,sizeof(d));
		for(i=0;i<2;i++){
			memset(f,0,sizeof(f)); 
			f[y[i]][x[i]]=1;
			q.push(room(x[i],y[i],1));
			ma=0;
			e=0;
			d[i][0]=0;
			while(!q.empty()){
				room cr=q.top();
				q.pop();
				e++;
				ma=MAX(ma,cr.l);
				d[i][e]=ma;
				//printf("%d\n",ma);
				for(k=0;k<4;k++){
					cx=cr.x+dx[k];
					cy=cr.y+dy[k];
					if(L[i][cy][cx]>=0 && f[cy][cx]==0){
						q.push(room(cx,cy,L[i][cy][cx]));
						f[cy][cx]=1;
					}
				}
			}
			//printf("END%d\n",i);
			
			/*for(j=1;j<=r;j++){
				//if(d[i][i]==0)d[i][j]=d[i][j-1];
				//printf("%d %3d ->%d\n",i,j,d[i][j]);
			}*/
		}
		ans=100000005;
		for(i=0;i<=w[0]*h[0];i++){
			if(d[0][i]!=-1 && d[1][r-i]!=-1 && r-i>=0 && r-i<=w[1]*h[1])ans=min(ans,d[0][i]+d[1][r-i]);
		}
		printf("%d\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 6604