akhauriyash/Code-Regression huggingface dataset:
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

v1 = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            v1 += 1

import bisect

A.sort()
v2 = 0
for a in A:
    v2 += bisect.bisect_left(A, a)

mod = 10 ** 9 + 7
ans = (v1 * K) % mod

if K > 1:
    tmp = (K - 1) % mod
    tmp = (tmp * K // 2) % mod
    # print(tmp)
    ans += tmp * v2
ans = ans % mod

# for i in range(1, K):
#     ans += (v2 * i) % mod
#     ans = ans % mod
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  cout << fixed << setprecision(10);
  vector<double> x(n), y(n);
  REP(i, n) { cin >> x[i] >> y[i]; }
  vector<vector<double>> dist(n, vector<double>(n));
  double ans = 0;
  REP(i, n) REP(j, n) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    dist[i][j] = sqrt(dx * dx + dy * dy);
    ans += dist[i][j];
  }

  ans /= 1.0 * n;

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

//クラス名は必ずMainにする必要があります。



public class Main {
    public static void main(String args[] ) throws Exception {
		Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        char[] s_c = s.toCharArray();
        char[] t_c = t.toCharArray();
        int num = 0;
        for(int i = 0; i < s.length(); i++){
            if(s_c[i] != t_c[i]){
                num++;
            }
        }
        System.out.println(num);
 	}
}

Measured memory_bytes: 42076
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		int[] inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int H = inputintArray[0];
		int W = inputintArray[1];
		int N = int.Parse(Console.ReadLine());
		int[] a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		
		
		string ans = "";
		List<int> color = new List<int>();

		for(int l = 0;l < N; l++)
		{
			for(int j = 0;j < a[l]; j++)
			{
				color.Add(l + 1);
			}
		}

		int cnt = 0;
		Boolean flg = true;
		int tmp = 0;
		int val = 1;
		for (int l = 0; l < H; l++)
		{
			ans = "";
			if (flg)
			{
				tmp = 0;
				val = 1;
			}
			else
			{
				tmp = W - 1;
				val = -1;
			}
			for(int j = tmp; j < W && j >= 0; j += val)
			{
				if (flg)
				{
					ans += color[cnt] + " ";
				}
				else
				{
					ans = color[cnt] + " " + ans;
				}
				cnt++;
			}
			flg = !flg;
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 17888
// https://atcoder.jp/contests/abc109/tasks/abc109_d
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
inline int read() {
    int tmp = 0;
    char c = getchar(), f = 1;
    for (; c < '0' || '9' < c; c = getchar())
        if (c == '-')
            f = -1;
    for (; '0' <= c && c <= '9'; c = getchar())
        tmp = (tmp << 3) + (tmp << 1) + c - '0';
    return tmp * f;
}

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    int h, w;
    h = read(), w = read();
    vector<vector<int>> v(h, vector<int>(w));
    REP(i, h) REP(j, w) v[i][j] = read();
    bool coin = false;
    vector<pii> ans, tmp;
    REP(i, h) REP(j, w) {
        int k = (i % 2 == 0 ? j : (w - j - 1));
        if (coin) {
            // ボールの合計が奇数の場合、ボールを持ったまま終わることを考慮
            tmp.push_back({i + 1, k + 1});
        }
        if (v[i][k] % 2 == 1) {
            if (coin) {
                coin = false;
                copy(ALL(tmp), back_inserter(ans));
                // ans.insert(ans.end(), ALL(tmp));
                tmp.clear();
            } else {
                coin = true;
            }
        }
        if (coin) {
            tmp.push_back({i + 1, k + 1});
        }
    }
    // cout << ans.size() / 2 << "\n";
    // REP(i, ans.size()) {
    //     cout << ans[i].first << " " << ans[i].second << (i % 2 ? "\n" : " ");
    // }
    printf("%lu\n", ans.size() / 2);
    REP(i, ans.size()) {
        printf("%d %d%c", ans[i].first, ans[i].second, (i % 2 ? '\n' : ' '));
    }

    return 0;
}


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

int main() {
  // input
  int N;
  cin >> N;
  
  vector<string> pos(N);
  for(int i=0; i<N; i++){
    cin >> pos.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<string> neg(M);
  for(int i=0; i<M; i++){
    cin >> neg.at(i);
  }
  
  // scoring
  int ans= 0;
  
  for(int i=0; i<N; i++){// 青色カードの方は探索済のワードを""に置き換えていく
    if( pos.at(i)=="" ) continue;
    else{
      int score= 0;
      string word= pos.at(i);
      
      for(int j=i; j<N; j++){
      	if( pos.at(j)==word ){
          pos.at(j)="";
          score++;
        }
      }
      for(int j=0; j<M; j++){
      	if( neg.at(j)==word ){
          score--;
        }
      }
      
      if( ans < score ) ans= score;
    }
  }
  
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k,s,cnt;
int main(){
    cin>>k>>s;
    for(int x=0;x<=k;x++)
        for(int y=0;y<=k;y++)
            if(s>=x+y&&s-x-y<=k) cnt++;
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int n;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	vi legs;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		legs.pb(a);
	}
	sort(legs.begin(), legs.end());

	int c = 0;
	for (int i = 0; i < n - 2; i++)
	{
		for (int j = i + 1; j < n - 1; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (legs[i] + legs[j] > legs[k] && legs[i] != legs[j] && legs[i] != legs[k] && legs[j] != legs[k])
					c++;
			}
		}
	}
	cout << c;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    long long n;
    cin >> n;

    vector<int> v(n);
    for(long long i = 0; i < n; i++){
        long long val;
        cin >> val;
        v[val]++;
    }

    long long ans = 1;
    if(n % 2 == 0){
        for(long long i = 0; i < n; i++){
            if(i % 2 == 0 && v[i] != 0) ans = 0;
            if(i % 2 == 1 && v[i] != 2) ans = 0;
            if(i % 2 == 0 )ans *= 2;
            ans = ans % 1000000007;
        }
        cout << ans << endl;
    }
    else if(n % 2 == 1){
        if(v[0] != 1) ans = 0;
        for(long long i = 1; i < n; i++){
            if(i%2 == 1 && v[i] != 0) ans = 0; 
            if(i%2 == 0 && v[i] != 2) ans = 0;
            if(i%2 == 0)ans *= 2;
            ans = ans % 1000000007;
        }
        cout << ans << endl;
    }


}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main() {

	string s;

	while(getline(cin, s)) {
		for(int i=0; i<s.size(); i++) {
			if(s[i]>='a'&&s[i]<='z')
				s[i]+=('A'-'a');
		}
		cout << s << endl;
	}


	return 0;

}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
using namespace std;

int N, W; long long D[100100];

int main()
{
	scanf("%d %d", &N, &W);

	for (int j=1;j<=100000;j++) D[j] = 1e16;
	for (int i=1;i<=N;i++){
		int w,v; scanf ("%d %d",&w,&v);
		for (int j=100000-v;j>=0;j--) if (D[j+v] > D[j] + w) D[j+v] = D[j] + w;
	}
	for (int i=100000;i>=0;i--) if (D[i] <= W){
		printf ("%d\n",i);
		break;
	}

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string n; cin>>n;
    rep(i,0,3){
        if(n[i]=='1') n[i]='9';
        else n[i]='1';
    }
    cout<<n<<endl;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  int A[N];
  int counter = 0;

  for (int i = 0; i < N; i++)
    cin >> A[i];

  int total = 0;
  for (int i = 0; i < N; i++)
  {
    total += A[i];
  }
  for (int i = 0; i < N; i++)
  {

    if (A[i] * 4 * M >= total)
    {
      counter++;
    }
  }
  if (counter >= M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> P;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int main(void) {
  int dp[50010];
  int coins[21];
  int N, M;

  cin >> N >> M;
  rep(i, 50010) { dp[i] = INF; }
  dp[0] = 0;
  rep(i, M) { cin >> coins[i]; }

  for (int i = 0; i < M; i++) {
    int val = coins[i];
    int count = 1;
    for (int j = 0; j <= N - val; j++) {
      dp[j + val] = min(dp[j + val], dp[j] + 1);
    }
  }

  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 3296
//arc098_d.cpp
//Wed Jan 29 22:07:10 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n];
	int kt[n][20];
	for (int i=0;i<n;i++){
		cin >> a[i];
		for (int j=0;j<20;j++){
			kt[i][j] = a[i]>>j & 1;
//			cout << kt[i][j] << " ";
		}
//		printf("\n");
	}

	int curketa[20];
	fill(curketa,curketa+20,0);

	int l = 0;
	int r = 0;
	int flag = 2;
	int testflag = 0;
	ll ans = 0;
	while (l<n){
//		cout << l << " " << r << " " << flag << " " << ans << endl;
		for (int i=0;i<20;i++){
			if (r<n && flag==2){
				curketa[i] += kt[r][i];
			}
			if (curketa[i]>1){
				testflag = 1;
			}
//			cout << curketa[i] << " ";
		}
//		printf("\n");
		if (testflag==1 || r==n){
			ans += r-l;
			for (int i=0;i<20;i++){
				curketa[i] -= kt[l][i];
			}
			l++;
			flag = 0;
			testflag = 0;
		}else{
			r++;
			flag = 2;
		}
	}

	cout << ans << endl;

//	printf("%.4f\n",ans);
}

Measured memory_bytes: 16640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedInputStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPalindromePhilia solver = new BPalindromePhilia();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPalindromePhilia {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int ans = 0;
            int i = 0, j = s.length - 1;
            while (i < j) {
                if (s[i] != s[j]) {
                    ++ans;
                }
                ++i;
                --j;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private StringTokenizer st;
        private BufferedReader reader;

        public InputReader(InputStream is) {
            st = null;
            reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(is, 1 << 18)));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

    }
}



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

int main() {
  int n,m;
  cin >> n >> m;
  
  priority_queue<ll> q ;

  rep(i,n) {
      ll k;
      cin >> k;
      q.push(k);
  }

  while(m>0){
      ll max = q.top();
      q.pop();
      q.push(max/2);
      m--;
  }

  ll ans =0;

  while(!q.empty()){
      ans += q.top();
      q.pop();

  }

  cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(j < A ^ i < B){
                cout << 0;
            } else {
                cout << 1;
            }
        }
        cout << endl;
    }
}


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

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

    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    } else if (b < 0 && (b - a) % 2 == 0) {
        cout << "Negative" << endl;
    } else {
        cout << "Positive" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc174/tasks
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define ip1(arr, n) for(int i=1; i<=n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define inf 1e9
#define INF 1e16
#define MOD 1000000007


int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n,d;
    cin>>n>>d;

    ll ans=0;
    for(int i=0; i<n; i++){
        ll x,y;
        cin>>x>>y;
        ans += ((x*x + y*y) <= (d*d));
    }
    cout<<ans<<endl;
    return 0;
}

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

int n,m;

inline int qr()
{
	int x=0,w=1;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	n=qr();
	while(n>0)
		n=n-1000;
	cout<<abs(n)<<endl;
	return 0;
} 

Measured memory_bytes: 3604
#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 vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);


void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	map<int, int> mp;
	rep(i, n)mp[a[i]]++; int ans = 0;
	per(j, 31) {
		int k = 1 << j;
		rep(i, n) {
			int x = a[i];
			if (x > k)continue;
			int r = k - x;
			if (x == r) {
				if (mp[x] >= 2) {
					ans ++; mp[x] -= 2;
				}
			}
			else {
				if (mp[x] > 0 && mp[r] > 0) {
					ans++; mp[x]--; mp[r]--;
				}
			}
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 30460
n, *XY = map(int, open(0).read().split())
X, Y = XY[::2], XY[1::2]
A = [x+y for x, y in zip(X, Y)]
B = [x-y for x, y in zip(X, Y)]
print(max(max(A) - min(A), max(B) - min(B)))

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

int main() {
   int N,M;
   cin >> N >> M;
   int cnt=0,ans=0;
   int like[30][30];

  //二次元配列likeを0ベクトルにする
   for(int i=0;i<30;i++){
     for(int j=0;j<30;j++){
       like[i][j]=0;
     }
   }

//0ベクトルになった配列likeのうちi人目がj番目を好きな場合(i,j)=1とする
  for(int i=0;i<N;i++){
   int K; cin >> K;
     for(int j=0;j<K;j++){
       int a;
       cin >> a;
       like[i][a-1] = 1;
     }
  }

//二次元配列likeのうち縦ベクトルがすべて１の列の数を数える。
  for(int j=0;j<M;j++){
    for(int i=0;i<N;i++){
      if(like[i][j] == 1){
       cnt++;
      }
    }
   if(cnt==N){
   ans++;
   }
   cnt=0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    map<string, int> mp;
    string s;
    cin >> n;
    for(int i=0;i<n;++i) {
        cin >> s;
        ++mp[s];
    }

    string t[4] = {"AC", "WA", "TLE", "RE"};
    for(int i=0;i<4;++i) {
        cout << t[i] << " x " << mp[t[i]] << endl;
    }
}


Measured memory_bytes: 3664
package main

import (
	"fmt"
)

func main() {
	var n, a, b, c, d int
	var s string
	fmt.Scan(&n, &a, &b, &c, &d, &s)
	var f bool
	f = false
	for i := a; i < c - 1; i++ {
		if s[i] == '#' {
			if f {
				fmt.Println("No")
				return
			}
			f = true
		} else {
			f = false
		}
	}
	f = false
	for i := b; i < d - 1; i++ {
		if s[i] == '#' {
			if f {
				fmt.Println("No")
				return
			}
			f = true
		} else {
			f = false
		}
	}
	if c > d {
		for i := b - 2; i < d - 1; i++ {
			if s[i] == '.' && s[i+1] == '.' && s[i+2] == '.' {
				fmt.Println("Yes")
				return
			}
		}
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.L;
		long p=100;
		for(int i = 1;;i++) {
			p+=p/100;
			if(p>=n){
				Console.WriteLine(i);
				return;
			}
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27488
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N, d[105];

set<int> st;

int main(){
    cin >> N;

    rep(i,N) {
        cin >> d[i];
        st.insert(d[i]);
    }

    cout << st.size() << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x=c-a, y=d-b;
    cout << c-y << " " << d+x << " " << a-y << " " << b+x << endl;
    return 0;
}

Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (ma (read))
         (mb (read))
         ;; ma, mb
         (dp (make-array (list (+ n 1) 401 401)
                         :element-type 'uint32
                         :initial-element #xffffffff)))
    (declare (uint8 ma mb n))
    (setf (aref dp 0 0 0) 0)
    (dotimes (i n)
      (let ((a (read))
            (b (read))
            (c (read)))
        (declare (uint8 a b c))
        (dotimes (suma 401)
          (dotimes (sumb 401)
            (setf (aref dp (+ i 1) suma sumb)
                  (min (aref dp (+ i 1) suma sumb)
                       (aref dp i suma sumb)))
            (when (and (<= (+ suma a) 400)
                       (<= (+ sumb b) 400))
              (setf (aref dp (+ i 1) (+ suma a) (+ sumb b))
                    (min (aref dp (+ i 1) (+ suma a) (+ sumb b))
                         (+ c (aref dp i suma sumb)))))))))
    (loop for a from ma to 400 by ma
          for b from mb to 400 by mb
          minimize (aref dp n a b) into res
          finally (println
                   (if (= res #xffffffff)
                       -1
                       res)))))

#-swank(main)


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

int main()
{
    vector<int> n(3);
    for (size_t i = 0; i < n.size(); i++)
    {
        cin >> n.at(i);
    }

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

    cout << n[0] << " " << n[1] << " " << n[2] << endl;
}



Measured memory_bytes: 3128
#include<iostream> 
#include<string> 
using namespace std; 
int main(){ string str; int n; while(cin >> str){ if(str=="-") break; cin >> n; for(int i=0,h;i<n;i++){ cin >> h; string cat = str.substr(0,h); str.erase(0,h); str+=cat; } cout << str << endl; } }


Measured memory_bytes: 3176
n, m = map(int, input().split())
populars = list(map(int, input().split()))
populars.sort(reverse=True)

flag = "Yes"
for i, item in enumerate(populars):
    if item < sum(populars)*(1/(4*m)):
        flag = "No"
    if i >= m-1 : break
print(flag)

Measured memory_bytes: 3060
#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<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
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++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

const string yey = "Yay!";
const string sad = ":(";

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end());
	int pl, ml;
	rep(i, n) {
		if (a[i] >= 0) {
			ml = i, pl = n - i;
				
			break;
		}
	}
	if (ml == 0) {
		ml = 1, pl = n - 1;
	}
	if (a.back() < 0) {
		pl = 1, ml = n - 1;
	}
	int sum = 0;
	rep(i, n) {
		if (i < ml)sum -= a[i];
		else sum += a[i];
	}
	int memo = a[0];
	vector<P> ans;
	Rep(i, ml, n - 1) {
		ans.push_back({ memo,a[i] });
		memo -= a[i];
	}
	ans.push_back({ a[n - 1], memo });
	memo = a[n - 1] - memo;
	Rep(i, 1, ml) {
		ans.push_back({ memo,a[i] });
		memo -= a[i];
	}
	cout << sum << endl;
	rep(i, ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(9);
	//init();
	//while (cin >> n>>m>>l,n)solve();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 3188
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  ll A;
  double B;
  cin >> A >> B;
  ll ans = A * (ll)(B * 100 + 0.5);
  cout << ans / 100 << endl;
  return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, r, p, c;
    while (cin >> n >> r && n > 0)
    {
        int inds[n];
        for (int i = 0; i < n; i++)
        {
            inds[i] = n - i;
        }

        for (int i = 0; i < r; i++)
        {
            cin >> p >> c;
            rotate(inds, inds + p - 1, inds + p - 1 + c);
        }
        cout << inds[0] << endl;
    }

    return 0;
}


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

int main(){

  int i;
  int n;
  int *a;


  scanf("%d",&n);
  a = (int *)malloc(sizeof(int) * n);

  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);

  }

  for(i = 0; i < n; i++){
    printf("node %d: key = %d, ", i + 1, a[i]);
    if(i != 0){
      if((i + 1) % 2 == 0) printf("parent key = %d, ", a[(i + 1) / 2 - 1]);
      else printf("parent key = %d, ", a[i / 2 - 1]);
    }
    if((i + 1) * 2 <= n) printf("left key = %d, ", a[(i + 1) * 2 - 1]);
    if((i + 1) * 2 + 1 <= n) printf("right key = %d, ", a[(i + 1) * 2]);
    printf("\n");
  }

  free(a);

  return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
A = ILs(N)
B = A[:]
B.sort()

MAX1 = B[-1]
MAX2 = B[-2]

for a in A:
  if a == MAX1:
    P(MAX2)
  else:
    P(MAX1)


Measured memory_bytes: 61536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <atcoder/all>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;
std::string S[110];

ll id( ll i, ll j )
{ return i*M+j; }

int main() {
  std::cin >> N >> M;

  atcoder::mf_graph<ll> G( N*M+10 );

  rep( i, N ) {
    std::cin >> S[i];
  }

  ll s = N*M, t = N*M+1;

  rep( i, N ) rep( j, M ) {
    if( (i+j)&1 ) {
      G.add_edge( id(i,j), t, 1 );
    } else {
      G.add_edge( s, id(i,j), 1 );
    }
  }

  rep( i, N ) rep( j, M ) {
    if( S[i][j] == '#' )
      continue;

    if( i+1 < N && S[i+1][j] != '#' ) {
      ll u = id(i,j), v = id(i+1,j);

      if( (i+j)&1 ) {
        std::swap( u, v );
      }

      G.add_edge( u, v, 1 );
    }

    if( j+1 < M && S[i][j+1] != '#' ) {
      ll u = id(i,j), v = id(i,j+1);

      if( (i+j)&1 ) {
        std::swap( u, v );
      }

      G.add_edge( u, v, 1 );
    }
  }

  std::cout << G.flow( s, t ) << endl;

  for( auto e : G.edges() ) {
    if( e.from >= s || e.to >= s )
      continue;

    if( e.flow == 1 ) {
      ll si = e.from/M, sj = e.from%M;
      ll ti = e.to/M, tj = e.to%M;

      if( si != ti ) {
        if( si > ti ) {
          std::swap( si, ti );
          std::swap( sj, tj );
        }

        S[si][sj] = 'v';
        S[ti][tj] = '^';
      } else {
        if( sj > tj ) {
          std::swap( si, ti );
          std::swap( sj, tj );
        }

        S[si][sj] = '>';
        S[ti][tj] = '<';
      }
    }
  }

  rep( i, N )
    std::cout << S[i] << endl;

  return 0;
}

Measured memory_bytes: 6180
#include<cstdio>
#include<cstdlib>
#include<cstring>

typedef struct list{
	int key;
	list *prev,*next;
}list;


list *nil;

void Insert(int num){
	list *tmp = new list;
	tmp->key = num;
	
	tmp->next = nil->next;
	tmp->prev = nil;
	
	tmp->next->prev = tmp ;
	nil->next = tmp;
}

void Delete(list *p){
	p->prev->next = p->next;
	p->next->prev = p->prev;
	
	delete p;
}

void Delete(int num){
	list *count = nil;
	while(count->next!=nil){
		count = count->next;
		if(count->key==num){
			Delete(count);
			break;
		}
	}
}

void DeleteFirst(){
	Delete(nil->next);
}

void DeleteLast(){
	Delete(nil->prev);
}



int main(){
	nil = new list;
	nil->prev = nil-> next = nil;
	
	int n;
	scanf("%d",&n);
	getchar();
	
	
	for(int i=0;i<n;i++){
		char input[32];
		fgets(input,32,stdin);
		
		char *order,*num;
		order = strtok(input," ");
		num = strtok(NULL," ");
		
		if(strcmp(order,"insert")==0){
			Insert(atoi(num));
		}else if(strcmp(order,"delete")==0){
			Delete(atoi(num));
		}else if(strcmp(order,"deleteFirst\n")==0){
			DeleteFirst();
		}else if(strcmp(order,"deleteLast\n")==0){
			DeleteLast();
			
		}
		
	}
	
	for(list *i = nil;i->next!=nil;i=i->next){
		if(i!=nil){
			printf(" ");
		}
		printf("%d",i->next->key);
	}
	printf("\n");
	
	
	
	
}

Measured memory_bytes: 33840
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
using namespace std;

int hash[244140625];

int get_char(char ch){
  switch(ch){
    case 'A' :
    return 1;
    case 'C' : 
    return 2;
    case 'G' : 
    return 3;
    case 'T' : 
    return 4;
  };
}

int getkey(string str){
  int sum = 0;
  int p = 1;
  for(int i=0;i<str.size();i++){
    sum += p*get_char(str[i]);
    p *= 5;
  }
  return sum;
}

int main(void){
  int n;
  cin >> n;
  vector<int> out;
  for(int i=0;i<n;i++){
    string str, word; 
    cin >> str >> word;

    int key = getkey(word);
    if(str == "insert"){
      hash[key] = 1;
    }else{
      if(hash[key]){
        out.push_back(1);
      }else {
        out.push_back(0);
      }
    }
  }

  for(int i=0;i<out.size();i++){
    if(out[i]){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 41184
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string S; int p[3];
int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		p[S[i] - 'a']++;
	}
	int V1 = max({ p[0], p[1], p[2] });
	int V2 = min({ p[0], p[1], p[2] });
	if (V1 - V2 >= 2) { cout << "NO" << endl; }
	else { cout << "YES" << endl; }
	return 0;
}

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

int main(){
  ll W,H,x,y;
  cin >> W >> H >> x >> y;
  ll s=W*H;
  printf("%.12f",s/2.0);
  //cout << s;
  cout << " ";
  int cnt=0;
  if(x*2==W && y*2==H)cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	String s = sc.next();
      	String t = sc.next();
      	
      	char[] slist = new char[3];
      	for(int i = 0; i < s.length(); i++){
          	slist[i] = s.charAt(i);
        }
      	
      	char[] tlist = new char[3];
      	for(int i = 0; i < t.length(); i++){   	
          	tlist[i] = t.charAt(i);
        }
      	
      	int result = 0;
      
      	for(int i = 0; i < slist.length; i++){
          	if(slist[i] == tlist[i]){
            	result += 1;
            }
        }
      
      System.out.println(result);
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());

            int[] p = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int ans = 0;
            for (int i = 1; i < n -1; i++)
            {
                int preP = p[i - 1];
                int P = p[i];
                int afterP = p[i + 1];

                if((preP <= P && P <= afterP)|| (afterP <= P && P <= preP))
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int[] NM = IntLine();
        int N = NM[0], M = NM[1];

        Node[] n = new Node[N];
        for (int i = 0; i < N; i++) n[i] = new Node(i);
        for (int i = 0; i < M; i++)
        {
            int[] b = IntLine();
            n[b[0] - 1].to.Add(b[1] - 1);
            n[b[1] - 1].flow_in++;
        }

        Queue<Node> q = new Queue<Node>();
        for (int i = 0; i < N; i++)
        {
            //始点となり得るものから探索
            if (n[i].flow_in == 0) q.Enqueue(n[i]);
        }

        int[] dp = new int[N + 10];

        while (q.Count() != 0)
        {
            Node dn = q.Dequeue();
            foreach (int to in dn.to)
            {
                dp[to] = Math.Max(dp[to], dp[dn.name] + 1);
                n[to].flow_in--;
                if (n[to].flow_in == 0) q.Enqueue(n[to]);
            }
        }
        Console.WriteLine(dp.Max());
    }
}

public class Node
{
    public List<int> to = new List<int>();
    public int name;
    public int flow_in = 0;
    public Node(int n) { name = n; }
}

public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(c).Select(int.Parse).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 29220
N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
    for j in range(i + 1, N):
        d = j - i
        k = j + d
        if k > N-1:
            break
        if {S[i], S[j], S[k]} == {'R', 'G', 'B'}:
            ans -=1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    int n, k;
    cin >> n >> k;
    string p;
    cin >> p;
    vector<int> z;
    int r = 0;
    for (int i = 0; i < n; i++) {
        if (p.at(i) == '0' && z.size() % 2 == 0) {
            z.push_back(r);
            r = 1;
        }
        else if (p.at(i) == '1' && z.size() % 2 == 1) {
            z.push_back(r);
            r = 1;
        }
        else { r++; }
    }
    z.push_back(r);
    if (z.size() % 2 == 0)z.push_back(0);
    if (z.size() <= 2 * k + 1)cout << n << endl;
    else {
        int t = 0;
        for (int i = 0; i < 2*k+1; i++) {
            t += z.at(i);
        }
        int ans = t;
        for (int i = 0; i < n*2; i+=2) {
            if (z.size() <= 2 * k + 2 + i)break;
            t -= z.at(i)+z.at(i+1);
            t += z.at(2 * k + 1 + i) + z.at(2 * k + 2 + i);
                ans = max(ans, t);
                
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll x, y; cin >> x >> y;
	if (x == 0) {
		if (y < 0) {
			cout << abs(y) + 1 << endl;
		} else {
			cout << y << endl;
		}
	} else if (y == 0) {
		if (x <= 0) {
			cout << abs(x) << endl;
		} else {
			cout << abs(x) + 1 << endl;
		}
	} else if (x * y > 0 && x <= y) {
		cout << abs(x - y) << endl;
	} else if (x * y > 0 && x > y) {
		cout << abs(x - y) + 2 << endl;
	} else {
		cout << abs(abs(x) - abs(y)) + 1 << endl;
	}

	return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

long long res = 0;
int n;

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		if(i % 3 != 0 && i % 5 != 0){
			res += i;
		}
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 3784
N = int(input())
A = input().split()
B = input().split()

dic = []
S = [0,0]
minus = [0,0]
for i in range(N):
    a = int(A[i])
    b = int(B[i])
    S[0]+=a
    S[1]+=b
    k = a-b
    if k >= 0:
        dic.append(k)
    else:
        minus[0]+=1#回数
        minus[1]+=k#値
if S[0] < S[1]:
    print(-1)
    exit()

lis = sorted(dic,reverse=True)

n=0
while minus[1]<0:
    minus[0]+=1
    minus[1]+=lis[n]
    n+=1


print(minus[0])
    # if a < b:
    #     break
    # if i == N-1:
    #     print(0)
    #     exit()
# if sum(A) < sum(B):
#     print(-1)

#差を調べる、辞書 A<Bの数を調べる

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

using namespace std;

int main() {
    double a, b, C, S, L, h;
    cin >> a >> b >> C;
    S = 0.5 * a * b * sin(C * M_PI / 180.0);
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * M_PI / 180.0));
    h = 2 * S / a;
    printf("%f\n%f\n%f\n", S, L, h);
    return 0;
}


Measured memory_bytes: 3404