akhauriyash/Code-Regression huggingface dataset:
/*
* Problem link
* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1191&lang=jp
*/

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

struct INIT{INIT(){cin.tie(0);ios_base::sync_with_stdio(false);} }init;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG if(0)

template<typename T> bool chmin(T& l, T r) {
	bool h = l > r; 
	if (h)l = r;
	return h;
}
template<typename T> bool chmax(T& l, T r) {
	bool h = l < r;
	if (h)l = r;
	return h;
}


int N,M,R;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<VVV> VVVV;

VV AB(2);
VV G;
VV X;
V Y;

VVV calc(int id) {
	auto v = AB[id];
	int n = v.size();
	REP(i, n)v.push_back(v[i]);
	VVV dp(2*n, VV(2*n + 1, V(31,-1)));
	VVVV can(R, VVV(2 * n, VV(2 * n + 1, V(11, -1))));

	function<int(int, int, int, int)> f = [&](int e,int l,int r,int pos) {
		int &ret = can[e][l][r][pos];
		if (ret >= 0)return ret;
		if (l == r&&pos == 0)return ret = 1;
		if (pos == 0)return ret = 0;
		if (l == r)return ret = 0;
		FOR(i, l, r) {
			if (f(e, l, i, pos - 1) && dp[i][r][X[e][pos - 1]] == 1)
				return ret = 1;
		}
		return ret = 0;
	};
	REP(i, 2 * n)dp[i][i + 1][v[i]] = 1;
	FOR(len, 2, n + 1) {
		REP(i, 2*n) REP(k,31){
			int j = i + len;
			if (j > 2 * n )break;
			dp[i][j][k] = 0;
			for (auto& e : G[k]) {
				int sz = X[e].size();
				if (sz > len)continue;				
				dp[i][j][k] |= f(e, i, j, sz);
			}
		}
	}
	return dp;
}

int solve() {
	int res = -1;
	auto aa = calc(0);
	auto bb = calc(1);
	VVVV edge(2*N, VVV(2*M));
	REP(a,2*N)FOR(b,a+1,2*N+1){
		REP(c, 2 * M)FOR(d, c + 1, 2 * M + 1)if(a+N>=b&&c+M>=d){
			REP(i, 31) {
				if (aa[a][b][i] == 1 && bb[c][d][i] == 1) {
					edge[a][c].push_back({ b - a,d - c });
					break;
				}
			}
		}
	}
		
	REP(aaa, N)REP(bbb, M) {
		VV can(N + 1, V(M + 1, -114514));
		can[0][0] = 0;
		REP(i, N)REP(j, M)if (can[i][j] >= 0) {
			for (auto &it : edge[i + aaa][j + bbb]) {
				if (i + it[0] <= N&&j + it[1] <= M) {
					auto &c = can[i + it[0]][j + it[1]];
					chmax(c, can[i][j] + 1);

				}
			}
		}
		chmax(res, can[N][M]);
	}
	return res;

}
int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	while (true) {
		cin >> N >> M >> R;
		if (N == 0)break;
		V a(N),b(M);
		REP(i, N)cin >> a[i];
		REP(i, M)cin >> b[i];
		VV g(31);
		VV x(R);
		V y(R);
		REP(i, R) {
			int k,t;
			cin >> k;
			REP(j, k) {
				cin >> t;
				x[i].push_back(t);
			}
			cin >> y[i];
			g[y[i]].push_back(i);
		}
		AB[0] = a;
		AB[1] = b;
		G = g;
		X = x;
		Y = y;
		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 62280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());

  int ans = INFINITY;
  rep(i, 100) {
    int tmp = 0;
    rep(j, n) {
      tmp += (x[j] - i + 1) * (x[j] - i + 1);
    }
    ans = min(ans, tmp);
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	
	ll arr[1000005],i;
	for(i=1;i<=1000000;i++)
	{
		if(i%3==0&&i%5==0)
			arr[i]=0;
		else if(i%3==0)
			arr[i]=0;
		else if(i%5==0)
			arr[i]=0;
		else
			arr[i]=i;
	}
	ll n;
	cin>>n;
    for(i=2;i<=1000000;i++)
    	arr[i]=arr[i]+arr[i-1];
    cout<<arr[n];
      return 0;
	
}

Measured memory_bytes: 11448
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



ll ans[26];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);


  ll N ; cin >> N;
  vector<string>S;
  bool check[26] ;
  rep(i,26){
    check[i] = false;
  }

  rep(i,N){
    string inp; cin >> inp ;
    S.pb(inp);
    rep(j,inp.size())
      check[inp[j]-'a'] = true;
  }
  rep(i,26) if(check[i])ans[i] = 1000000;
  
  rep(i,N){
    string str = S[i];
    ll temp[26]; rep(i,26) temp[i] = 0;
    rep(j,str.size())
      temp[str[j]-'a']++;

    rep(j,26)
      if(check[j]) ans[j] = min(ans[j],temp[j]);
        
  }

  string ret = "";
  rep(i,26){
    rep(j,ans[i]){
      ret += (char)('a' + i);
    }
  }
  cout << ret << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int s1 = Integer.parseInt(lines[0]);
            int s2 = Integer.parseInt(lines[1]);
            int s3 = Integer.parseInt(lines[2]);
            if (s1 + s2 + s3 == -3) {
                break;
            }
            int sum = s1 + s2;
            String result = "";
            if (s1 == -1 || s2 == -1) {
                result="F";
            } else if (sum >= 80) {
                result = "A";
            } else if (sum >= 65) {
                result = "B";
            } else if (sum >= 50) {
                result = "C";
            } else if (sum >= 30) {
                result = "D";
                if (s3 >= 50) {
                    result = "C";
                }
            } else {
                result = "F";
            }
            System.out.println(result);
        }
    }
}

Measured memory_bytes: 24328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define fi first
#define sc second
int n;
ll a[200005];
multiset<pair<ll,int> >M;
multiset<pair<int,ll> >rM;
ll ans[200005];
int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		M.insert(mp(-a[i],i));
		rM.insert(mp(i,-a[i]));
	}
	M.insert(mp(1e18,0)); M.insert(mp(1e18,n+1));
	rM.insert(mp(0,1e18)); rM.insert(mp(n+1,1e18));
	ans[0] = 0;
	for(int num=1;num<=n/2;num++){
		pair<ll,int> p = *M.begin();
		ans[num] = ans[num-1] - p.first;
		if(num==n/2){
		cout << ans[num] << endl;
		}
		multiset<pair<int,ll> >::iterator it = rM.lower_bound(mp(p.sc,-1e18));
		it--;
		pair<int,ll>a = *it;
		M.erase(M.find(mp(a.sc,a.fi)));
		rM.erase(it++);
		pair<int,ll>b = *it;
		M.erase(M.find(mp(b.sc,b.fi)));
		rM.erase(it++);
		pair<int,ll>c = *it;
		M.erase(M.find(mp(c.sc,c.fi)));
		rM.erase(it++);
		rM.insert(mp(b.fi,a.sc+c.sc-b.sc));
		M.insert(mp(a.sc+c.sc-b.sc,b.fi));
	}
}

Measured memory_bytes: 30968
SET=["dreamer", "dream",  "eraser", "erase"]
S=input()
dp=[0]*100010
dp[0]=1
for i in range(len(S)):
  if not dp[i]:continue
  for j in SET:
    if S[i:i+len(j)]==j:
      dp[i+len(j)]=1
if dp[len(S)]==1:print("YES")
else:print("NO")

Measured memory_bytes: 3956
#include <stdio.h>

#define N 10000

int     tbl[ N + 1 ] = { 0 };
size_t  tbln = 0;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( j = 2; j <= N; ++j )
  {
    if ( tbl[ j ] ) continue ;

    for ( i = j * 2; i <= N; i += j )
    {
      tbl[ i ] = 1;
    }
  }
  for ( i = 2; i <= N - 2; ++i )
  {
    if ( !tbl[ i ] && !tbl[ i + 2 ] )
    {
      tbl[ tbln++ ] = i + 2;
    }
  }

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 1; i < tbln && tbl[ i ] <= n; ++i ) ;

    printf ( "%d %d\n", tbl[ i - 1 ] - 2, tbl[ i - 1 ] );
  }

  return ( 0 );
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            
            string s = "";
            s = s.PadLeft(M+2,'#');
            
            for(int i = 0 ; i < N+2 ; i++)
            {
                if(i==0 || i == N+1)
                {
                    Console.WriteLine(s);
                }
                else
                {
                    Console.WriteLine("#"+Console.ReadLine()+"#");
                }
            }
        }
    }
}

Measured memory_bytes: 13140
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  n<-readInt
  yesNoUpper $ sort n == [5,5,7]

Measured memory_bytes: 380
Option Strict On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim S As String = NextString()

        Dim maximum_value As Integer = 0
        Dim cnt As Integer = 0

        For i As Integer = 0 To N - 1
            cnt += Calc(S(i))
            maximum_value = Math.Max(maximum_value, cnt)
        Next

        WriteLine(maximum_value)
    End Sub

    Function Calc(c As Char) As Integer
        Select Case c
            Case "I"c
                Return 1
            Case "D"c
                Return -1
            Case Else
                Return 0
        End Select
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  vector<ll> sum(N);
  sum[0] = A[0];
  repp(i, 1, N - 1) {
    sum[i] = sum[i - 1] + A[i];
  }

  ll ans = LINF;
  repp(c, 1, N - 2) {
    ll l = sum[c];
    auto iter = lower_bound(all(sum), (double)l / 2.0);
    int pos = distance(sum.begin(), iter);
    ll P = sum[pos], Q = l - P;
    if (abs(P - Q) > abs((P - A[pos]) - (Q + A[pos]))) {
      P -= A[pos];
      Q += A[pos];
    }

    ll r = sum[N - 1] - sum[c];
    iter = lower_bound(all(sum), l + (double)r / 2.0);
    pos = distance(sum.begin(), iter);
    ll R = sum[pos] - l, S = r - R;
    if (abs(R - S) > abs((R - A[pos]) - (S + A[pos]))) {
      R -= A[pos];
      S += A[pos];
    }
    chmin(ans, max({P, Q, R, S}) - min({P, Q, R, S}));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define INF 5000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,u,k;
int head = 0,tail = 0;
int queue[N],color[N],d[N];

int M[N][N];

void enqueue(int u);
int dequeue(void);
void bfs(void);/*引数*/

int main()
{
    int i,j,v;
    
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(j = 0;j < k;j++){
            scanf("%d",&v);
            v--;
            M[u][v] = 1;
        }
    }
    bfs();
    
    for(i = 0;i < n;i++){
        if(d[i] == 5000) printf("%d %d\n",i+1,-1);
        else printf("%d %d\n",i+1,d[i]);
    }
    
    return 0;
}

void bfs(void)
{
    int i,q;
    for(i = 0;i < n;i++){
        color[i] = WHITE;
        d[i] = INF;
    }
    color[0] = GRAY;
    d[0] = 0;
    enqueue(0);
    while(head != tail){
        q = dequeue();
        for(i = 0;i < n;i++){
            if(M[q][i] == 1){
                if(color[i] == WHITE){
                    color[i] = GRAY;
                    d[i] = d[q] + 1;
                    enqueue(i);
                }
            }
        }
        color[q] = BLACK;
    }
}

void enqueue(int u)
{
    int next = (tail+1)%N;
    if(next == head){
        printf("Queue overflow\n");
        exit(1);
    }
    queue[tail] = u;
    tail = next;
}

int dequeue(void)
{
    int val;
    
    if(head == tail){
        printf("Queue empty\n");
        exit(2);
    }
    val = queue[head];
    head = (head+1)%N;
    return val;
}





Measured memory_bytes: 2148
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(std::string S){
  for(auto &x : S)
    x = 'x';
  std::cout << S << std::endl;
    
}

int main(){
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}
/*
Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z =malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}


void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
      if ( com[0] == 'f' ){
     scanf("%d", &x);
     Node t = treeSearch(root, x);
     if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      }
  if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
  } //else if ( com[0] == 'd' ){
  //scanf("%d", &x);
  //  treeDelete(treeSearch(root, x));
  //}
  }

  return 0;
}



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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int p, q, r, s;
	cin >> p >> q >> r >> s;
	puts(p == r ? "0" : "1");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

string make_ans(int x, int y) {
    string str;
    int m = 100000;
    int r = x;
    rep(i, 6) {
        int e = r / m;
        char c = (char) e + '0';
        str += c;
        r -= m * e;
        m /= 10;
    }
    int m2 = 100000;
    int r2 = y;
    rep(i, 6) {
        int e = r2 / m2;
        char c = (char) e + '0';
        str += c;
        r2 -= m2 * e;
        m2 /= 10;
    }
    return str;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<tuple<int,int,int>> tp(m);
    rep(i, m) {
        int y, p;
        cin >> p >> y;
        tp[i] = {y, p, i};
    }
    sort(all(tp));
    map<int,int> mp;
    vector<string> ans(m);
    rep(i, m) {
        int f = get<1>(tp[i]);
        int s = mp[f];
        ++s;
        ++mp[f];
        int k = get<2>(tp[i]);
        ans[k] = make_ans(f, s);
    }
    rep(i, m) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 12240
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  int sum=0;
  cin >> N;
  REP(i,N){
    int p;
    cin>>p;
    sum+=p-1;
  }
  print(sum);
  return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
 
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
 
A_p = p[:X]
B_q = q[:Y]
C_r = r
 
ans = A_p + B_q + C_r
ans.sort(reverse=True)
print(sum(ans[: X+Y]))

Measured memory_bytes: 23328
#include <math.h>
int i,n,x[1000],y[1000];
double t;
double Distance(int p){
    int i;
    for(t=0,0,i=0;i<n;i++){
        if(p==4)t=t>abs(x[i]-y[i])?t:abs(x[i]-y[i]);
        else t+=pow(1.0*abs(x[i]-y[i]),p);
    }
    return p==4?t:pow(t,1.0/p);
}
main(){
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&x[i]);
    for(i=0;i<n;i++)scanf("%d",&y[i]);
    for(i=1;i<5;i++)printf("%lf\n",Distance(i));
}

Measured memory_bytes: 1964
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

    struct UnionFind {
        vector<int> par;
    
        UnionFind(int n) : par(n, -1) { }
    
        int root(int x) {
            if (par[x] < 0) return x;
            else return par[x] = root(par[x]);
        }
    
        bool issame(int x, int y) {
            return root(x) == root(y);
        }
    
        bool merge(int x, int y) {
            x = root(x); y = root(y);
            if (x == y) return false;
            if (par[x] > par[y]) swap(x, y); // merge technique
            par[x] += par[y];
            par[y] = x;
            return true;
        }
    
        int size(int x) {
            return -par[root(x)];
        }
    };

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,m;
        cin>>n>>m;
        vl p(n);
        rep(i,n)cin>>p[i];
        UnionFind uf(n);
        rep(i,m){
            ll x,y;
            cin>>x>>y;
            x--;y--;
            uf.merge(x,y);
        }
        ll count=0;
        rep(i,n){
            if(uf.issame(p[i]-1,i))count++;
        }
        cout<<count<<endl;
    }

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

constexpr ll V = 1000000;

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret * x % MOD;
        x = x * x % MOD;
        y /= 2;
    }
    return ret;
}

ll N;
ll A[200000];
ll C[V+1];
ll C1[V+1];
ll C2[V+1];
ll w[V+1];
ll inv[V+1];

void init() {
    //for (ll i = 1; i <= V; i++) inv[i] = mod_pow(i, MOD-2);
    inv[1] = 1;
    for (ll i = 2; i <= V; i++) inv[i]=MOD-MOD/i*inv[MOD%i]%MOD;
    for (ll i = 1; i <= V; i++) {
        w[i] = (inv[i] - w[i]%MOD + MOD) % MOD;
        for (ll j = i*2; j <= V; j += i) {
            w[j] += w[i];
        }
    }
}

int main() {
    init();
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) C[A[i]]++;
    for (ll i = 1; i <= V; i++) {
        C1[i] = C[i] * i % MOD;
        C2[i] = C1[i] * i % MOD;
    }
    ll ans = 0;
    for (ll i = 1; i <= V; i++) {
        ll add = 0;
        ll sum1 = 0, sum2 = 0;
        for (ll j = i; j <= V; j += i) {
            sum1 += C1[j];
            sum2 += C2[j];
        }
        sum1 %= MOD;
        sum2 %= MOD;
        add = (sum1*sum1-sum2+MOD)%MOD;
        add = add * inv[2] % MOD;

        ans = (ans + add*w[i]) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 40832
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    A=input()
    B=input()
    C=''.join(list(reversed(B)))
    if A==C:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////.......................................w////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////ww/qee////////////////////////////////////////////////////////////////////////////////qe
int n,h,a,p;
int main() {
	cin>>n;
  //////////////////////////////////////////////////////////////////////////////////////////////////////////
	for(int i=0;i<n;i++) {
		cin>>h;
      ////////////////////////////////////////////////////////hello//do/you/hear/me//////////////////////////////////////////
		if(p<h)a+=h-p;
		p=h;
	}
  //nice/to/meet/you/>>>
  ///////////////////////////////////////
	cout << a << endl;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        a:[String;n],
    }
    //    mut  a:[f64;n],

    let mut b = vec![0i128; n];
    for i in 0..n {
        let st = a[i].clone();
        if let [s, t] = *st.split('.').collect::<Vec<_>>() {
            let mut num = 0;
            let s = s.parse::<i128>().unwrap();
            let m = t.len();
            let t = t.parse::<i128>().unwrap();
            num = s * 1000000000;
            let mut x = t;
            for _ in 0..9 - m {
                x *= 10;
            }
            num += x;
            b[i] = num;
        } else {
            let num = st.parse::<i128>().unwrap() * 1000000000;
            b[i] = num;
        }

        // b[i] = (a[i] * (1e9 + 1e-10) + 0.1) as i128;
    }
    let mut c = vec![];
    let mut tfs = vec![vec![0i64; 37]; 37];
    for &x in b.iter() {
        let mut two = 0;
        let mut five = 0;
        let mut y = x;
        while y % 2 == 0 {
            y /= 2;
            two += 1;
        }
        while y % 5 == 0 {
            y /= 5;
            five += 1;
        }

        if two >= 18 {
            two = 18;
        }
        if five >= 18 {
            five = 18;
        }

        c.push((two, five));
        tfs[two][five] += 1i64;
    }
    // dbg!(&b);
    let mut ans = 0i64;
    for &(two, five) in c.iter() {
        for i in 0..19 {
            for j in 0..19 {
                if two + i >= 18 && five + j >= 18 {
                    ans += tfs[i][j];
                }
            }
        }
        if two + two >= 18 && five + five >= 18 {
            ans -= 1;
        }
    }
    println!("{}", ans / 2);
}

const eps: f64 = 1e-10;


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

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> data(T+1, 0);
    for (int i = 0; i < N; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        data[a]++;
        data[b]--;
    }
    
    for (int i = 1; i <= T; i++) data[i] += data[i-1];
    
    cout << *max_element(data.begin(), data.end()) << endl;
    return 0;
}


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

typedef long long ll;

inline ll ceill(ll a, ll b) { return a/b + (a%b != 0); }

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    while(cin >> n) {
        ll a = 1, b = 1;
        for(int i = 0; i < n; i++) {
            ll x, y; cin >> x >> y;
            ll k = max(ceill(a,x), ceill(b,y));
            a = x*k; b = y*k;
        }
        cout << a+b << '\n';
    }
    return 0;
}

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

int W;
int A[100010];
int L[100010] = {},R[100010] = {};
int inf = 2e9;
int main(){
    cin >> W;
    for(int i=1;i<=W;i++){
        cin >> A[i];
    }
    for(int i=1;i<=W;i++){
        if(A[i]==0) L[i] = inf;
        else if(A[i]>0) L[i] = max(L[i-1]-1,0);
        else L[i] = min(max(L[i-1]-1,0),-A[i]);
    }
    for(int i=W;i>=1;i--){
        if(A[i]==0) R[i] = inf;
        else if(A[i]>0) R[i] = max(R[i+1]-1,0);
        else R[i] = min(max(R[i+1]-1,0),-A[i]);
    }
    int ans = 0;
/*    for(int i=1;i<=W;i++) cerr << L[i] << " ";
    cerr << endl;
    for(int i=1;i<=W;i++) cerr << R[i] << " ";
    cerr << endl;
*/    for(int i=1;i<=W;i++){
        if(A[i]<=0) continue;
        int l = 0,r = 0;
        ans += min(A[i],max(L[i],R[i]));
    }
    cout << ans << endl;
}


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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

int modpow(int a,int b,int p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n),s(n+1);
    s[0]=0;
    rp(i,n){
        cin >> a[i];
    }
    sort(a);
    rep(i,1,n){
        s[i]=s[i-1]+a[i-1];
    }
    int p=0;
    rep(i,1,n){
        if(a[i-1]>2*s[i-1]){
            p=i-1;
        }
    }
    cout << n-p << endl;
    
    return 0;
}


Measured memory_bytes: 1792
require 'set'

class Q1030
  def sim n,h,tri
    set = Set.new
    for i in 0..h-1
      arg = gets.split(" ")
      n1 = arg[1].to_i - 1
      n2 = arg[2].to_i - 1
      #puts "n1 = #{n1}, n2 = #{n2}"
      if(arg[0] == "xy")
        for j in 0..n-1
          set.add(tri.new(n1,n2,j))
        end
      elsif(arg[0] == "xz")
        for j in 0..n-1
          set.add(tri.new(n1,j,n2))
        end
      elsif(arg[0] == "yz")
        for j in 0..n-1
          set.add(tri.new(j,n1,n2))
        end
      end
    end
=begin
    for i in 0..n-1
      for j in 0..n-1
        for k in 0..n-1
          if(ary[i][j][k] == false)
            sum += 1
          end
        end
      end
    end
=end
    puts(n ** 3 - set.size)
  end
  def doIt
    arg = gets.split(" ").map{|x| x.to_i}
    tri = Struct.new("Triple", :x, :y, :z)
    while(0 < arg[0] + arg[1])
      sim arg[0],arg[1],tri
      arg = gets.split(" ").map{|x| x.to_i}
    end
  end
end

Q1030.new.doIt

Measured memory_bytes: 15156
N, X = map(int, input().split())
L = list(map(int, input().split()))

D = [0]
for i in range(N):
    d = D[i]+L[i]
    D.append(d)

a=0
for j in range(N+1):
    if D[j] <= X:
        a=a+1
    else:
        pass

print(a)


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

#define MOD (1000000000+7)

int main()
{
	long long n, k; 
	cin >> n >> k;

	long long ans = 1;
	for( int i = 0; i < n; i++ ) {
		ans = ( ans * k ) % MOD;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3136
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	vector< pii > C(N);
	rep(i, N) {
		C[i].first = B[i];
		C[i].second = A[i];
	}
	sort(C.begin(), C.end());
	vector< pii > A2(N);
	rep(i, N) {
		A2[i].first = C[i].second;
		A2[i].second = i;
	}
	sort(A2.begin(), A2.end());
	vector< int > cycle(N, -1);
	int c = 0;
	rep(i, N) {
		if (cycle[i] == -1) {
			++c;
			int j = i;
			while (cycle[j] == -1) {
				cycle[j] = A2[j].second;
				j = A2[j].second;
			}
		}
	}
	//cout << cycle;
	string ans = "Yes";
	rep(i, N) {
		if (A2[i].first > C[i].first)
			ans = "No";
	}
	if (ans == "Yes") {
		if (c >= 2) {
			ans = "Yes";
		} else {
			ans = "No";
			rep(i, N - 1) {
				if (C[i].first >= A2[i + 1].first) {
					ans = "Yes";
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()


int main() {
  int K,N;
  
  cin >> K >> N ;

  int sum=500*K;
  
  if(sum>=N) cout << "Yes" << endl;

  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
using namespace std;
long long inf=100000000000007;
#define int long long
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
char fi[1005][1005];
P sg[10];
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int c=0;
int n,m,t;
signed main(){
    int k=1;
    int n;cin>>n;
    int g=0;
    int a;
    for(int i=0; i<n; i++){
        k*=3;
        cin>>a;
        if(a%2==0)g++;
    }
    int count=1;
    for(int i=0; i<g;i++){
        count*=2;
    }
    cout<<k-count<<endl;
    return 0;
}


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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector<int> v(5);
    for(int i = 0; i < 5; i++){
        cin >> v[i];
    }
    for(int i = 0; i < 5; i++){
        if(v[i] == 0){
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3496
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
    a.append(a[i] + A[i])
    
for i in range(M):
    b.append(b[i] + B[i])
totaltime = 0
count,j = 0, M
 
for i in range(N+1):
    if a[i] > K:
        break
    while a[i] + b[j] > K:
        j -= 1
    count = max(count,i + j)
 
print(count)

Measured memory_bytes: 47552
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program
{
    static int x;
    static List<int> s = new List<int>();
    static string result;
    static void Main()
    {
        string[] tmp = Console.ReadLine().Split(' ');
        s.Add(int.Parse(tmp[0]));
        s.Add(int.Parse(tmp[1]));
        s.Add(int.Parse(tmp[2]));
        int results;
        results = s[2] - s[0] + s[1];
        if (results < 0) { results = 0; }
        if (results > s[2]) { results = s[2]; }
        result =results.ToString();
            Console.WriteLine(result);
            Console.Out.Flush();
        
    }

 


}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var h = ReadLine().Split().Select(int.Parse).ToArray();
        if (N == 2)
        {
            WriteLine(Math.Abs(h[1] - h[0]));
            return;
        }
        var dp = new int[N];
        dp[1] = Math.Abs(h[1] - h[0]);
        for (int i = 2; i < N; i++)
        {
            dp[i] = Math.Min(Math.Abs(h[i] - h[i - 1]) + dp[i - 1], Math.Abs(h[i] - h[i - 2]) + dp[i - 2]);
        }
        WriteLine(dp[N - 1]);
    }
}


Measured memory_bytes: 18016
#include <string>
#include <vector>
#include <utility>
#include <iostream>

using mass_t = std::vector<std::vector<char>>; 

bool can_paint() { return false; }

template <class Head, class... Tail>
bool can_paint(Head && head, Tail &&... tail) {
  return (head == '#') ? true : can_paint(std::forward<Tail>(tail)...);
}

mass_t make_mass(int H, int W) {
  mass_t mass;
  for (int h = 0; h < H; ++h) {
    std::string s; std::cin >> s;
    std::vector<char> v;
    for (int w = 0; w < W; ++w) {
      v.push_back(s[w]);
    }
    mass.push_back(v);
  }
  return mass;
}

std::string solve(const mass_t & mass) {
  const int H = mass.size();
  const int W = mass[0].size();
  bool yes { true };
  for (int h = 0; h < H - 2 && yes; ++h) {
    for (int w = 0; w < W - 2 && yes; ++w) {
      if (mass[h + 1][w + 1] == '#') {
        yes = can_paint(
            mass[h][w + 1],
            mass[h + 2][w + 1],
            mass[h + 1][w],
            mass[h + 1][w + 2]);
      }
    }
  }
  return yes ? "Yes" : "No";
}

int main() {
  int H, W;
  std::cin >> H >> W;
  std::cout << solve(make_mass(H, W)) << std::endl;
  return 0;
}


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

int main() {
  int x;
  cin >> x;
  
  int sum = 0;
  int i = 1;
  while(1){
    sum += i;
    if(sum >= x) break;
    i++;
  }
  
  cout << i << endl;

}

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

int main(int argc, char *argv[]) {
	int N = 0;
	int T = 0;
	int A = 0;
	std::vector<int> heights;

	std::cin >> N;
	std::cin >> T;
	std::cin >> A;
	double current_h;
	for (int i = 0; i < N; i++) {
		std::cin >> current_h;
		heights.push_back(current_h);
	}

	double min_temp_sub = DBL_MAX;
	double temp_sub = 0;
	double ave_temp = 0;
	int answer = 0;
	for(int j = 0; j < N; j++) {
		//
		//  浮動小数点として演算してほしいので、オペランドの
		//  ひとつは必ずdoubleにする。
		//  整数同士で演算してしまうと、結果の値は切り捨てられる
		//
		//  http://www.jpcert.or.jp/sc-rules/c-flp06-c.html
		//
		//  今回の場合は 0.006 が 浮動小数点リテラルなので、そのままでACできる
		//
		ave_temp = T - (heights[j] * 0.006);
		temp_sub = std::abs(A - ave_temp);
		if (temp_sub <= min_temp_sub) {
			min_temp_sub = temp_sub;
			answer = j + 1;
		}
	}

	std::cout << answer << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"
const int N = 1e6 + 10;


signed main()
{
    FAST;
    int t;
    t=1;
    
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        int a[n];
        map<int,int> mp,mp1;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
          maxx = max(maxx,a[i]);
            mp[a[i]]++;
        }
        
        ans=0;
        
        for(auto it : mp)
        {
            int num = it.first;
            count = it.second;
            if(num==1)
            {
                if(count==1)
                {
                    cout<<1<<endl;
                }
                
                else
                {
                    cout<<0<<endl;
                }
                return 0;
            }
            if(count==1 && mp1.count(num)==0)
            {
                ans++;
            }
            
            if(mp1.count(num)==0)
            {
                for(i=2;i*num<=maxx;i++)
                {
                    mp1[i*num]++;
                }
            }
            
        }
        
        cout<<ans<<endl;
        
        
    }
        
    
    
    
    
}


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

int compare_int(const void *a, const void *b){
    if(*(int*)a > *(int*)b) return 1;
    return -1;    
}

int main(){

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

    long max_no1=0;
    long max_no2=0;
    for(long i=0;i<n;i++){
        if(a[i]>max_no1){
            max_no2=max_no1;
            max_no1=a[i];
        }else if(a[i]>max_no2){
            max_no2=a[i];
        }
    }
    if(max_no1==max_no2){
        for(long i=0;i<n;i++){
            printf("%ld\n",max_no1);
        }
    }else{
        for(long i=0;i<n;i++){
            if(a[i]<max_no1){
                printf("%ld\n",max_no1);
            }else{
                printf("%ld\n",max_no2);
            }
        }
    }
    
/* 
    qsort(a,n,sizeof(int),compare_int);

    for(int i=0;i<n;i++){
        printf("%d\n",a[i]);
    }*/

    return 0;
}

Measured memory_bytes: 3072
#include<stdio.h>
int main(void){

	int a,b,c,n;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>b){
		n = a;
		a = b;
		b = n;
	}
	if(a>c){
		n = a;
		a = c;
		c = n;
	}
	if(b>c){
		n = b;
		b = c;
		c = n;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0 ;
}


Measured memory_bytes: 2060
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	long double a, b, h, m;
	cin >> a >> b >> h >> m;

	long double h_ = h * 30 + m * 0.5, m_ = m * 6;
	long double ans = a * a + b * b - 2 * a *b*cosl(M_PI * abs(h_ - m_) / 180.0);
	printf("%.15Lf\n", sqrtl(ans));

	return 0;
}

Measured memory_bytes: 4168