akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  int d,e;
  double mi=10000.0;
  double y;
  while(1){
    mi=10000;
    cin >>d>>e;
    if(d==0&&e==0)break;
    for(int i=0,j=d;i<d;i++,j--){
      y=sqrt(i*i+j*j);
      mi=min(fabs(y-e),mi);
    }
    printf("%.10f\n",mi);
  }
  return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define wh while
#define db double
#define pb .push_back
#define sz .size()
#define vc vector
#define vcd vector <double>
#define vcf vector <float>
#define vci vector <int>
#define vcs vector <string>
#define sti set <int>
#define str string
#define in .insert
#define fi .first
#define se .second
#define yes true
#define no false
#define bg .begin()
#define ed .end()
#define ch char
#define ad a,b,c,d
#define till n i<n.size();
vci A;
vci B;
sti G;
bool t;
bool f;
bool y=yes;
int main(){
    int n,a;
    cin>>n>>a;
    if(n==a){
        cout<<"Yes";
    }
    else
        cout<<"No";
}


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


void solve(long long N, long long W, vector<tuple<long long, long long>> ws){
  vector<vector<long long>> dp(N, vector<long long>(W+1, -1));

  dp[0][get<0>(ws[0])] = get<1>(ws[0]);

  for(long long i = 1; i < N; i++){
    dp[i][get<0>(ws[i])] = max(dp[i][get<0>(ws[i])], get<1>(ws[i]));

    for(long long j = 0; j <= W; j++) {
      if(dp[i-1][j] == -1) continue;
      dp[i][j] = max(dp[i][j], dp[i-1][j]);

      long long myw = get<0>(ws[i]);
      long long myp = get<1>(ws[i]);

      if(j + myw <= W) dp[i][j + myw] = max(dp[i][j + myw], dp[i-1][j] + myp);
    }
  }


  cout << *max_element(dp[N-1].begin(), dp[N-1].end()) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long W;
  scanf("%lld",&W);
  vector<tuple<long long, long long>> ws;
  long long w, s;
  for(int i = 0 ; i < N ; i++){
    cin >> w >> s;
    ws.push_back(make_tuple(w, s));
  }
    solve(N, W, std::move(ws));
    return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
#include <vector>
#include <cmath>

using namespace std;

int main(){

	int a, b, ans=0, tmp;
	vector< vector<int> > board;
	vector<int> sq(10000);

	for(int i=0;i<10000;i++) sq[i]=i*i;

	cin>> a >> b;
	board.resize(a);
	for(int i=0;i<a;i++) board[i].resize(b);

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

	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++){
			tmp=0;
			for(int k=0;k<b;k++){
				tmp+=(board[i][k]-board[j][k])*(board[i][k]-board[j][k]);
			}
			for(int k=0;k<10000;k++){
				if(tmp==sq[k]){
					ans++;
					break;
				}
			}
		}
	}

	cout<< ans << endl;

}

Measured memory_bytes: 256
import sys

inf = 1<<60

def solve():
    N, M = map(int, input().split())
    edges = [None] * M

    for i in range(M):
        ai, bi, ci = map(int, sys.stdin.readline().split())
        ai, bi = ai - 1, bi - 1
        edges[i] = (ai, bi, -ci)

    ans = BellmanFord(N, M, edges)

    if ans is None:
        print('inf')
    else:
        print(-ans)

def BellmanFord(N, M, edges):
    d = [inf] * N
    d[0] = 0

    for i in range(N - 1):
        for (u, v, c) in edges:
            if d[u] + c < d[v]:
                d[v] = d[u] + c

    for i in range(N):
        for (u, v, c) in edges:
            if d[u] + c < d[v]:
                if v == N - 1:
                    return None

                d[v] = d[u] + c

    return d[N - 1]

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3404
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;


int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N;
	string S;
	cin >> N >> S;

	bool map1[10];
	bool map2[10][10];
	bool map3[10][10][10];
	for(int i=0; i<10; i++) {
		for(int j=0; j<10; j++) {
			for(int k=0; k<10; k++) {
				map3[i][j][k] = false;
			}
			map2[i][j] = false;
		}
		map1[i] = false;
	}

	int sum = 0;
	for(int i=0; i<S.size()-2; i++) {
		int d1 = (char)S[i] - '0';
		if(map1[d1]) continue;

		for(int j=i+1; j<S.size()-1; j++) {

			int d2 = (char)S[j] - '0';
			if(map2[d1][d2]) continue;

			for(int k=j+1; k<S.size(); k++) {

				int d3 = (char)S[k] - '0';
				if(map3[d1][d2][d3]) continue;

				// cout << S[i] << S[j] << S[k] << endl;

				map3[d1][d2][d3] = true;
				sum++;
			}

			map2[d1][d2] = true;
		}

		map1[d1] = true;
	}


	cout << sum;

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS

int N,M = 0;
int a[1000];
int main() {
	cin >> N >> M;
	for (int i = 0;i<N;i++){
		cin >> a[i];
	}
	sort(a, a + N);
	int sum = 0;
	int ans = 0;
	for (int i = 0; i <N ;i++) {
		if (i==N-1) {
			if (sum + a[N - 1] == M) {
				ans++;
			}
			break;
		}
		if (sum+a[i]<=M) {
			sum += a[i];
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
  static int A[] = new int[2000000];
  static int H = 0;
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String [] s = new String[2];
    while(true){
      s = br.readLine().split("\\s+");
      if(s[0].charAt(0) == 'i'){
        insert(Integer.parseInt(s[1]));
      }else if(s[0].charAt(1) == 'x'){
        System.out.println(heapExtractMax(A));
      }else{
        break;
      }
    }
  }

  static void insert(int key){
    H++;
    A[H] = (int)Double.NEGATIVE_INFINITY;
    heapIncreaseKey(A, H, key);
  }

  static void heapIncreaseKey(int A[], int i, int key){
    int tmp = 0;
    if(key<A[i]){
      return;
    }
    A[i] = key;
    while(i >1 && A[parent(i)]< A[i]){
      tmp = A[i];
      A[i] = A[parent(i)];
      A[parent(i)] = tmp;
      i = parent(i);
    }
  }

  static int heapExtractMax(int A[]){
    if(H<1){
      System.out.println("under flow");
      return (int)Double.NEGATIVE_INFINITY;
    }
    int max = A[1];
    A[1] = A[H--];
    maxHeapify(A, 1);

    return max;
  }

  static void maxHeapify(int A[], int i ){
    int l =i*2;
    int r = i*2+1;
    int largest = 0;
    int tmp;

    if(l<=H && A[l] > A[i]) largest = l;
    else largest = i;

    if(r<=H && A[r] > A[largest] ) largest = r;

    if(largest != i){
      tmp = A[i];
      A[i] = A[largest];
      A[largest] = tmp;
      maxHeapify(A, largest);
    }
  }
  static int parent(int i){
    return i/2;
  }

}


Measured memory_bytes: 551232
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

using namespace std;

int32_t main(){
      string s;
      cin >>s;
      for(int i = 1; i < SZ(s); i ++){
            if(s[i] == s[i - 1])
                  return cout <<"Bad" <<endl, false;
      }
      cout <<"Good" <<endl;
      return false;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(2019, 0);
  int p_x[n];
  for(int i = 0; i < n; i++) cin >> p_x[i];
  int m;
  cin >> m;
  //vector<int> a(2019, 0);
  int ob_num[m];
  for(int i = 0; i < m; i++) cin >> ob_num[i];


  vector<pair<int, int>> pos_num;
  for(int i = 0; i < n; i++) {
    x[p_x[i]-1] = 1;
  }


  for(int i = 0; i < n; i++) {
    if(ob_num[i] != i+1){
      pos_num.push_back(make_pair(p_x[i], i+1));
    }
    else {
      pos_num.push_back(make_pair(p_x[i], ob_num[i]));
    }
  }

/*
  for(int i = 0; i < n; i++) {
    cout << pos_num[i].first << " " << pos_num[i].second << endl;
  }
*/

/*
for(int i = 0; i < 2019; i++) {
  if(x[i] != 0) {
    cout << i + 1 << endl;
  }
}
*/
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < n; j++) {
      if(pos_num[j].second == ob_num[i]) {
        //cout << " a " << pos_num[j].first-1 << "b " << x[pos_num[j].first-1] <<  " c " << pos_num[j].first << " d " << x[pos_num[j].first] << endl;

        if(pos_num[j].first-1 < 2018 && x[pos_num[j].first] != 1) {
          x[pos_num[j].first-1] = 0;
          x[pos_num[j].first] = 1;
          pos_num[j].first += 1;
        }

        //}
        else if(pos_num[j].first-1 == 2018){
          x[pos_num[j].first-1] = 1;

          //x[pos_num[j].first] = 1;
          //x[pos_num[j].first-1] = 1;
          //x[pos_num[j].first] = 1;
        }

      }
      else if(pos_num[j].second > ob_num[i]) {
        break;
      }
     }
  }


  for(int i = 0; i < 2019; i++) {
    if(x[i] != 0) {
      cout << i + 1 << endl;
    }
  }
/*
  for(int i = 0; i < m; i++) {
    if()
  }
*/

}



Measured memory_bytes: 3088
from collections import deque

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

A.sort(reverse=True)

result = [A[0]]
space = deque(result)
point = 0

for a in A[1:]:
    s = space.popleft()
    point += s
    space.append(a)
    space.append(a)
print(point)

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n;
int cnt[150]={0};

int main()
{
	IOS;
	cin >> n;
	cnt[0]=1;
	for (int i = 0; i < 100; i++) {
		if (cnt[i]) {
			cnt[i+4]=1;
			cnt[i+7]=1;
		}
	}
	(cnt[n])?printf("Yes\n"):printf("No\n");
	return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //test only

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  char s;
  cin >> s;
  if(s >= 'A' && s <= 'Z') cout << 'A' << endl;
  else cout << 'a' << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
template <class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = INT_MAX;
const int MOD = 1000000007;

int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int ngcd(vector<int> a){
    int result;
    result = a[0];
    for(int i = 1; i < a.size() && result != 1; i++) {
        result = gcd(result, a[i]);
    }
    return result;
}

int main() {
    int N, K;
    cin >> N >> K;
    vi A(N);
    rep(i, N) cin >> A[i];
    int a_max = MAX(A);
    if (K > a_max) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int gcd = ngcd(A);
    if (K % gcd == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>
#include<vector>
using namespace std;
bool flag=false;
vector<int> v[100005];
vector<int> way;
bool vis[100005];
bool visited[100005];
int n;
int m;
int l;
int r;
bool dfs_find_way(int a){
    vis[a]=true;
    way.push_back(a);
    if(a==n){
        return true;
    }
    for(int i=0;i<v[a].size();i++){
        if(!vis[v[a][i]]){
            if(dfs_find_way(v[a][i])){
                return true;
            }
        }
    }
    way.pop_back();
    return false;
}
int dfs_get_ans(int a,int num=0){
    visited[a]=true;
    for(int i=0;i<v[a].size();i++){
        if(!visited[v[a][i]]){
            num=dfs_get_ans(v[a][i],num+1);
        }
    }
    return num;
}
int main(){
    cin>>n;
    m=n-1;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs_find_way(1);
    for(int i=0;i<way.size();i++){
        visited[way[i]]=true;
    }
    for(int i=0;i<(way.size()+1)/2;i++){
        l+=dfs_get_ans(way[i],0);
    }
    for(int i=(way.size()+1)/2;i<way.size();i++){
        r+=dfs_get_ans(way[i],0);
    }
    if(l>r){
        puts("Fennec");
        return 0;
    }
    else if(l<r){
        puts("Snuke");
        return 0;
    }
    else{
        if(way.size()%2==0){
            puts("Snuke");
            return 0;
        }
        else{
            puts("Fennec");
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 9592
r,c = map(int, input().split())

EX_list = []

for i in range(r):
    EX_list.append(input().split())
for i in range(r):
    r_sum = 0
    for j in EX_list[i]:
        r_sum += int(j)
    EX_list[i].append(r_sum)
    print(*EX_list[i])

c_sum_list = []
for c_i in range(c):
    c_sum = 0
    for r_i in range(r):
        c_sum += int(EX_list[r_i][c_i])
    c_sum_list.append(c_sum)
c_sum_list_sum = 0
for i in c_sum_list:
    c_sum_list_sum += i
c_sum_list.append(c_sum_list_sum)
print(*c_sum_list)


Measured memory_bytes: 6728
def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(n, k))


Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 305;

int n, m, mod;
ll ans, c[maxn][maxn], dp[maxn][maxn], f[maxn][maxn];

void init()
{
	c[0][0] = 1;
	for(int i = 1; i <= n; ++i)
	{
		c[i][0] = 1;
		for(int j = 1; j <= i; ++j)
			c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod;
	}
}

int main()
{
	scanf("%d%d%d", &n, &m, &mod);
	init();
	for(int i = 0; i <= m; ++i)
		dp[1][i] = 1;
	for(int i = 1; i <= n + 1; ++i)
	{
		for(int j = 0; j <= m; ++j)
		{
			for(int k = 1; k < i; ++k)
				dp[i][j] = (dp[i][j] + ((dp[i-k][j] * f[k][j+1] % mod) * c[i-2][k-1] % mod)) % mod;
		}
		for(int j = m; j >= 0; --j)
			f[i][j] = (f[i][j+1] + dp[i][j]) % mod;
	}
	printf("%lld", dp[n+1][0]);
	return 0;
}


Measured memory_bytes: 2432
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func nextStringLine(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = nextString()
	}
	return s
}

type Pair struct {
	i int
	j int
}

const INF = 100100100

func main() {
	sc.Split(bufio.ScanWords)
	H, W := nextInt(), nextInt()

	S := make([][]string, H)
	for i := 0; i < H; i++ {
		S[i] = make([]string, W)
		str := nextString()
		for j := 0; j < W; j++ {
			S[i][j] = string(str[j])
		}
	}

	DI := [4]int{-1, 0, 1, 0}
	DJ := [4]int{0, -1, 0, 1}

	distMax := 0

	for si := 0; si < H; si++ {
		for sj := 0; sj < W; sj++ {
			if S[si][sj] == "#" {
				continue
			}
			// init queue
			queue := []Pair{{si, sj}}

			// init dist
			dist := make([][]int, H)
			for i := 0; i < H; i++ {
				dist[i] = make([]int, W)
				for j := 0; j < W; j++ {
					dist[i][j] = INF
				}
			}
			dist[si][sj] = 0

			for len(queue) > 0 {
				p := queue[0]
				queue = queue[1:]

				for k := 0; k < 4; k++ {
					di := p.i + DI[k]
					dj := p.j + DJ[k]
					if 0 <= di && di < H && 0 <= dj && dj < W && dist[di][dj] == INF && S[di][dj] == "." {
						queue = append(queue, Pair{di, dj})
						dist[di][dj] = dist[p.i][p.j] + 1
					}
				}
			}
			max := getMax(dist, H, W)
			if max > distMax {
				distMax = max
			}
		}
	}
	fmt.Println(distMax)
}

func getMax(list [][]int, h, w int) int {
	max := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if max < list[i][j] && list[i][j] != INF {
				max = list[i][j]
			}
		}
	}
	return max
}


Measured memory_bytes: 5504
/**
 * author: moririn_cocoa       
**/

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

int main(void) {
  
  int N;
  int M;
  
  cin >> N;
  cin >> M;
  
  if ( N == M ) {
    
    cout << "Yes" << endl;
  }
  
  else if ( N != M ) {
    
    cout << "No" << endl;
  }

return 0;
}


Measured memory_bytes: 3636
N = int(input())
H = list(map(int, input().split()))

ans = 'Yes'
tmp_max = H[-1]

for h in reversed(H[:-1]):
    if h <= tmp_max:
        tmp_max = h
    elif h-1 <= tmp_max:
        tmp_max = h-1
    else:
        ans = 'No'

print(ans)


Measured memory_bytes: 85408
/*
 *  Created on: 31 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

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

//const ld PI = acos(-1);
//const ll mod = 1e15 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ld a, b; cin >> a >> b;
    ld x = a * b;
    ll ans = x;
    cout << ans;
}

Measured memory_bytes: 3748
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = a % 10;
        if(b == 2 || b == 4 || b == 5 || b == 7 || b == 9 ){
            System.out.println("hon");
        }else if(b == 0 || b == 1 || b == 6 || b == 8){
            System.out.println("pon");
        }else if(b == 3){
            System.out.println("bon");
        }
        
    }
}

Measured memory_bytes: 35736
import sys

def search_next(nextbutton : int) -> int:
    nextbutton = a.index(nextbutton) +1
    return nextbutton

n = int(input())
a = [int(input()) for i in range(n)]
nextbutton = 1
count = 0

#print(nextbutton,"first")

for _ in range(n):
    if nextbutton == 2:
        print(count)
        #print(nextbutton,"1")
        
        sys.exit()
    else:
        nextbutton = a[nextbutton -1]
        #print(nextbutton,"el")
        
        count += 1
print(-1)

Measured memory_bytes: 7084
#include <iostream>
#include <vector>
#include <queue>
#define rep(i,n) for (int i=0; i <(n); ++i)
using namespace std;


int main() {
  string T;
  cin >> T;
  int size = T.size();
  int count = 0;
  for (int i=0; i < size; i++) {
    if (T[i]=='?')
      T.replace(i, 1, "D");
  }

cout << T << endl;
}



Measured memory_bytes: 3756
n = int(input())
s_w = input()
r_cnt = sw_cnt = 0

for s in s_w:
  if s == 'R':
    r_cnt += 1
    
for i, s in enumerate(s_w):
  if i>=r_cnt and s!= 'W':
    sw_cnt += 1
print(min(sw_cnt, r_cnt, n-r_cnt))

Measured memory_bytes: 67976
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    VI water, suger;
    FOR(i, 0, f)FOR(j, 0, f){
        int x = i * a * 100 + j * b * 100;
        int y = i * c + j * d;
        if(x <= f) water.push_back(x);
        if(y <= f) suger.push_back(y);
    }

    int ans_w = water.back();
    int ans_s = suger.front();
    for(auto w : water)for(auto s : suger){
        if(w + s > f || s > e * w / 100) continue;
        if((w + s) * ans_s < s * (ans_w + ans_s)){
            ans_w = w;
            ans_s = s;
        }
    }
    cout << ans_w + ans_s << " " << ans_s << "\n";
    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define INF 999999
using namespace std;
int a[11] = { 0 };

bool fin(int x)
{
	while (x)
	{
		if (a[x % 10]) return 0;
		x /= 10;
	}
	return 1;
}

int main()
{
	int n, k, t;
	int flag = 0;
	cin >> n >> k;
	for (int i = 1; i <= k; i++)
	{
		cin >> t;
		a[t] = 1;
	}
	while (true)
	{
		if (fin(n)) break;
		n++;
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
// using namespace boost::multiprecision;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define ers erase
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

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

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll N;
    cin >> N;

    vi c(N);
    ll rn = 0;
    rep (i, N) {
        char wr;
        int b;
        cin >> wr;

        b = (wr == 'W') ? 0 : 1;
        if (b == 1) rn++;
        c[i] = b;
    }

    ll cnt = 0;
    rep (i, rn) {
        if (c[i] == 0) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 4036
x, n = input().split()

x = int(x)
n = int(n)

def check(x,n):
    # そもそも配列の数が0の場合は中断
    if int(n) == 0:
        print(x)
        return

    # 与えられた変数の配列
    p_list = input().split()

    # 差数を１ずつ上昇させていってみる
    for i in range(0, 100):
        min_x = str(x - int(i))
        max_x = str(x + int(i))

        # 片方
        if min_x not in p_list or max_x not in p_list:
            if min_x not in p_list:
                print(min_x)
                return
            
            if max_x not in p_list:
                print(max_x)
                return
        
        # 両方
        if min_x not in p_list and max_x not in p_list:
            print(min_x)
check(x,n)

Measured memory_bytes: 9240
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    const A = arg[1].split(" ").map(Number);
    
    let sum = A.reduce((m,n)=>m+n);
    let popular = 0;
    
    for(let i in A) {
        const limit = sum * (1 / (4 * M));
        
        if(A[i] >= limit) {
            popular++;
        }
    }

    console.log(popular >= M ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[333]; Scs(s);
    int N = strlen(s);

    int cnt;
    int tmp;
    int ans = 1331;
    Repe(ci,'z'+1,'a'){
        cnt = 0;
        tmp = 0;
        Rep(i,N){
            if( s[i] == ci ) tmp = max( tmp, cnt ), cnt = -1;
            cnt++;
        }
        tmp = max( tmp, cnt );
        ans = min( ans, tmp );
    }

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

    return 0;
}



Measured memory_bytes: 256
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll n, s=0;
    cin>>n;
    vector<ll> v(n);
    rep(i,0,n){
        cin>>v[i];
        v[i]-=i+1;
    }
    sort(begin(v), end(v));
    rep(i,0,n){
        s+=abs(v[i]-v[n/2]);
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

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

int main()
{
    string S;
    cin >> S;
    int N = S.size();
    vint cnt(N + 1);
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'B')
            cnt[i + 1] = cnt[i] + 1;
        else
        {
            cnt[i + 1] = cnt[i];
        }
    }

    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'W')
        {
            ans += cnt[i];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1300
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 2000200
#define mod 1000000007
using namespace std;
namespace IO{
	int Top=0;char SS[20];
	void write(int x){
		if(!x){putchar('0');return;} if(x<0) x=-x,putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0; char cw=getchar(); for(;!isdigit(cw);cw=getchar());
		for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0'); return nm;
	}
}using namespace IO;
int add(int x,int y){return (x+y>=mod)?x+y-mod:x+y;} 
int mul(int x,int y){return (LL)x*(LL)y%mod;}
void upd(int &x,int y){x=add(x,y);}
int n,m,F[M],S[M],ans;
int main(){
	n=read(),F[0]=S[0]=1;
	for(int i=1;i<=n;i++) F[i]=i>2?S[i-3]:0,upd(F[i],F[i-1]),S[i]=add(S[i-1],F[i]);
	for(int i=0;i<n;i++) upd(ans,mul(F[i],i+(i<n-1)));
	for(int i=0;i<n-1;i++) upd(ans,mul(F[i],mul(n-1,n-1)));
	upd(ans,F[n]),write(ans),putchar('\n');return 0;
}

Measured memory_bytes: 10496
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    P = get_li()
    Q = list(range(1, n+1))
    diff = 0
    for p, q in zip(P, Q):
        if p != q:
            diff += 1
    if diff == 0 or diff == 2:
        print('YES')
    else:
        print('NO')
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 63724
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 1000000007

#define MAXR 100000
#define PI 3.14159265358979323846

    using namespace std;

signed main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    int sum = 0;
    int ans = 0;
    REP(i, n){
        cin >> A[i];
        sum += A[i];
        sum %= MOD;
    }
    //cout << sum <<endl ;

    REP(i,n){
        sum -= A[i];
        if (sum < 0) sum += MOD;
        
        int a = A[i] * sum;
        
        //cout <<"a"<<a   <<endl ;
      //  a = a % MOD;
        ans += a;
        ans = ans % MOD;
    }

    cout << ans <<endl ;



    return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int N;
  cin>>N;
  LL a[N+1];
  REP(i, N+1) a[i]=0;
  a[1]=1;
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  int work;
  FOR(i, 2, N+1){
    work = i;
    FOR(j, 2, i+1){
      while(work%j==0){
          ++a[j];
          work /= j;
      }
    }
  }
  LL ans=1;
  FOR(i, 2, N+1){
    ans=ans*(a[i]+1)%MOD;
  }
  //REP(i, N+1)cout<<a[i]<<endl;
  cout<<ans<<endl;


  return 0;
}


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

a = list() 
for i in range(n):
  a.append(int(input()))

aSorted = sorted(a,reverse=True)

stackNum = 1 #first is 1  
for j in range(len(aSorted)):
  if j == len(aSorted)-1:
    break
  if aSorted[j] > aSorted[j+1]:
    stackNum += 1

print(stackNum)
 

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,m,v,p;
  cin>>n>>m>>v>>p;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  sort(as.begin(),as.end());

  auto check=
    [&](Int pos)->Int{
      vector<Int> bs;
      for(Int i=0;i<n;i++)
        if(i!=pos) bs.emplace_back(as[i]);

      reverse(bs.begin(),bs.end());

      Int sum=0,cnt=0;
      for(Int b:bs){
        if(b>as[pos]+m){
          cnt++;
          continue;
        }
        if(cnt+1<p){
          cnt++;
          continue;
        }
        // b <= as[pos]+m
        sum+=min(m,as[pos]+m-b);
      }
      // cout<<as[pos]<<":"<<sum<<" "<<cnt<<endl;

      // muri
      if(cnt>=p) return 0;

      // ok
      return sum>=m*max(0LL,v-(cnt+1));
    };

  Int L=-1,R=n;
  while(L+1<R){
    Int M=(L+R)>>1;
    if(check(M)) R=M;
    else L=M;
  }
  cout<<n-R<<endl;
  return 0;
}


Measured memory_bytes: 3000
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m, c = sc.nextInt()
  val bs = Array.fill(m)(sc.nextInt())
  val loop = 0 until m
  println {
    List.fill(n)(Array.fill(m)(sc.nextInt())).count { as =>
      0 < loop.map(i => bs(i) * as(i)).sum + c
    }
  }
}

Measured memory_bytes: 27724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 2010

int n, m;
int cnt[1000100];

int main(){
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	REP(i, n) {
		cout << cnt[i + 1] << endl;
	}
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    map<char, ll> m;
    string S;
    cin >> S;
    for(auto &i: S) {
        if(m[i]) {
            cout << "no" << endl;
            return 0;
        }
        m[i]++;
    }
    cout << "yes" << endl;
    return 0;
}


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

    vector < int > vec, ans;
    vector < bool > vis;

    int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n, res;
        long long k;    
        cin >> n >> k;
        vec.resize(n + 3);
        vis.resize(n + 3);
        for(int i = 1;i <= n;i++)   cin >> vec[i];
        int it = 1,x;
        while(!vis[it]){
            ans.push_back(it);
            vis[it] = true;
            it = vec[it];
            if(vis[it] == true){
                x = it;
            }
        }
        int before = 0;
        for(int s: ans){
            if(s == x)  break;
            before++;
        }
        if(k < before){
            res = ans[k];
        }
        else{
            k -= before;
            res = k % (ans.size() - before) + before;
            res = ans[res];
        }
            cout << res << "\n";

    	return 0;
}

Measured memory_bytes: 5048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nums = br.readLine().split(" ");
		long taka = Long.parseLong(nums[0]);
		long naka = Long.parseLong(nums[1]);
		long hiku = Long.parseLong(nums[2]);
		long k = Long.parseLong(nums[3]);

		long ans = 0;

		if (k % 2 == 0) {
			ans = taka - naka;

		} else {
			ans = naka - taka;
		}

		System.out.println(Math.pow(10, 18) < Math.abs(ans) ? "Unfair" : ans);

	}

}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
struct pree
{
	int x,y,cost;
};
inline bool compare(pree uu,pree vv)
{
	return uu.cost<vv.cost;
}
pree edge[MAXN];
int par[MAXN];
inline int parent(int pos)
{
	if(par[pos]!=pos)
	{
		par[pos]=parent(par[pos]);
	}
	return par[pos];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	pll a[n+1];
	vector<pli> v,v1;
	ll x,y;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		v.pb(mk(x,i));
		v1.pb(mk(y,i));
	}
	sort(v.begin(),v.end());
	sort(v1.begin(),v1.end());
	int sz=0;
	for(int i=0;i<v.size()-1;i++)
	{
		edge[sz].x=v[i].second;
		edge[sz].y=v[i+1].second;
		edge[sz].cost=abs(v[i].first-v[i+1].first);
		sz++;
	}
	for(int i=0;i<v1.size()-1;i++)
	{
		edge[sz].x=v1[i].second;
		edge[sz].y=v1[i+1].second;
		edge[sz].cost=abs(v1[i].first-v1[i+1].first);
		sz++;
	}
	sort(edge,edge+sz,compare);
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		par[i]=i;
	}
	for(int i=0;i<sz;i++)
	{
		pree p=edge[i];
		int p1=parent(p.x);
		int p2=parent(p.y);
		//cout<<p.x<<" "<<p.y<<" "<<p.cost<<"\n";
		if(p1!=p2)
		{
			par[max(p1,p2)]=min(p1,p2);
			ans=ans+p.cost;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 7908
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
const int inf=2147483647;
const int mo=924844033; 
const int N=4005;
using namespace std;
int n,m,tot;
bool lk[N];
long long f[N][N][2],jc[N],ans;
int main()
{
    scanf("%d%d",&n,&m);
    jc[0]=1;
    for(int i=1;i<=n;i++) jc[i]=1ll*jc[i-1]*i%mo;
    for(int i=1;i<=m;i++)
        for(int t=2;t--;)
            for(int j=i;j<=n;j+=m)
            {
                tot++;
                if(j!=i) lk[tot]=1;
            }
    f[0][0][0]=1;
    for(int i=0;i<n*2;i++)
        for(int j=0;j<=n;j++)
        {
            f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mo;
            if(lk[i+1]) f[i+1][j+1][1]=f[i][j][0];
        }
    for(int i=0,t=1;i<=n;i++,t=-t)
    {
        f[2*n][i][0]=1ll*(f[2*n][i][0]+f[2*n][i][1])*jc[n-i]%mo;
        ans=(ans+f[2*n][i][0]*t+mo)%mo;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 249472
N = int(input())
A = list(map(int,input().split()))
A_set = list(set(A))
l = [0]*(N+2)
ans = [0]*(N+2)
for a in A:
  l[a]+=1
comb = [0]*(N+2)
for i in range(2,N+1):
  comb[i] = i*(i-1)//2
  
for i in range(2,N+1):
  ans[i]=comb[i]-comb[i-1]
  
total = 0
for a in A_set:
  total += comb[l[a]]

for a in A:
  print(int(total-ans[l[a]]))

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

using namespace std;

#define il inline
#define re register int
#define Rep(i, s, e) for (re i = s; i <= e; ++i)
#define Dep(i, s, e) for (re i - s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout);

il int read() {
	int x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}

char s[110];
int main() {
	scanf("%s", s);
	Rep(i, 1, strlen(s)) putchar('x');
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int i,count=0;
	char str[5];
	scanf("%s",str);
	for(i=0;i<4;i++)
	{
		if(str[i]=='+')
		{
			count++;
		}
		else
		{
			count--;
		}
	}
	printf("%d\n",count);
	return 0;
} 

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

int main(){
  long long A,B,K;
  cin >> A >> B >> K;
  if(K<=A){
    cout << A-K << " " << B << endl;
  }
  else if(A+B<=K){
    cout << 0 << " " << 0 << endl;
  }
  else{
    cout << 0 << " " << B-K+A << endl;
  }
}

Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True
def cmb(n,r):  #nCr = n!/(n-r)!r!
    retVal = 1
    for i in range(n-r+1,n+1):
        retVal *= i
    for i in range(2,r+1):
        retVal //= i
    return retVal
def main():
    from collections import defaultdict
    N = int(input())
    d = defaultdict(lambda:0)
    base = ord('a')
    ans = 0
    for _ in range(N):
        s = input().strip()
        num = 0
        for c in s:
            num += 26 ** (ord(c) - base)
        ans += d[num]
        d[num] += 1

    
    print(ans)

        

    





    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 66012
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
		int a[]=new int[n];

		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		for(int j=n-1;j>=0;j--) {

			if(j==0) {
				System.out.println(a[j]);
				break;
			}
			System.out.print(a[j]+" ");
		}


	}

}



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

#define MAX_N 100000
#define MAX_D 20

class Node
{
    public:
    int parent = -1, depth = MAX_D + 1;
    vector<int> childs;
};

void set_depth(Node nodes[], Node *cur, int depth)
{
    cur->depth = depth++;
    for (auto itr = cur->childs.begin(); itr != cur->childs.end(); ++itr) {
        set_depth(nodes, nodes + *itr, depth);
    }
}

void print_nodes(Node nodes[], int n)
{
    int cnt = 0;
    for (int i = 0; cnt < n; i++) {
        if (nodes[i].depth == MAX_D + 1) continue;
        cout << "node " << i << ": "
        << "parent = " << nodes[i].parent << ", "
        << "depth = " << nodes[i].depth << ", "
        << (nodes[i].parent == -1 ? "root" : nodes[i].childs.size() == 0 ? "leaf" : "internal node") << ", ";
        cout << "[";
        for (auto itr = nodes[i].childs.begin(); itr != nodes[i].childs.end(); itr++) {
            if (itr != nodes[i].childs.begin()) cout << ", ";
            cout << *itr;
        }
        cout << "]" << endl;
        cnt++;
    }
}

int main()
{
    int n, id, k;
    Node nodes[MAX_N + 1], *root;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> id >> k;
        int c[k];
        for (int j = 0; j < k; j++) {
            cin >> c[j];
        }
        for (int *p = c; p != c + k; p++) {
            nodes[id].childs.push_back(*p);
            nodes[*p].parent = id;
        }
    }
    root = nodes + id;
    while (root->parent != -1) {
        root = nodes + root->parent;
    }
    set_depth(nodes, root, 0);
    print_nodes(nodes, n);
    return 0;
}

Measured memory_bytes: 7008
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};
void read(T...)  (auto ref T args)    { mixin(readMixin);}
void readArray(T)(auto ref T args)    { mixin(readMixin);}
int  read()                           { int n;read(n);return n;}
void times(int n,void delegate() stmt){ foreach(i;iota(n))stmt();}
auto dot(R1,R2)(R1 a,R2 b)            { ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}
struct infIota                        { int i=0;enum empty=false;int front(){return i;}void popFront(){i++;}}
void main(){
	int[] MS;
	for(int i = 6;i < 300000;i +=7)MS ~=[i,i+2];
	int n ;
	while(read(n),n!=1){
		write(n,":");
		int[] res;
		foreach(ms;MS){
			if(ms > n) break;
			if(n % ms == 0) {
				if(!res.any!(a => ms % a == 0)) res ~= ms;
			}
		}
		res.each!(a=> write(" ",a));
		writeln();
	}
}

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int mpow(int n){
        if(n%2){
                return -1;
        }else{
                return 1; 
        }  
}

int main(){
        int n; 
        cin >> n; 
        while(n){
                int n10[20];
                for(int i = 0; i < 20; i++){
                        n10[i] = n%10;
                        n /= 10;
                }  
                int m10[22] = {0};
                for(int i = 0; i < 20; i++){
                        m10[i] += n10[i]*mpow(i);
                        while(m10[i] < 0){
                                m10[i+1]++;
                                m10[i] += 10;
                        }  
                        while(m10[i] > 9){
                                m10[i+2] += 1; 
                                m10[i+1] += 9; 
                                m10[i] -= 10;
                        }  
                }  
                int idx = 19;
                while(!m10[idx]) idx--;
                while(idx+1){
                        cout << m10[idx];
                        idx--;
                }  
                cout << endl;
                cin >> n; 
        }  
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#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 s,w;
  cin >> s >> w;
  if(w>=s)cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}


Measured memory_bytes: 3636